So I have an QVector
called xarray
QVector< QString > xarray;
Now I want to draw the array
void MainWindow::paintEvent( QPaintEvent* e )
{
QPainter painter(this);
for(int i = 0; i < 5; i++)
{
qDebug() << "\r\narr : " <<QList<QString>::fromVector(xarray);
painter.drawEllipse(X, 10, 100, 100);
}
}
How can I give the array to my x comp ?
I tried
painter.drawEllipse(xarray[i], 10, 100, 100);
But there is no function for call to QPainter
.
I think you're looking for QString::toInt().
You have an array of QStrings but you need to pass an int to drawEllipse(), the overload that takes ints. You will need to convert your strings to integers.
A quick edit to your code would turn it into:
void MainWindow::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
for(int i = 0; i < 5; i++)
{
qDebug() << "\r\narr : " <<QList<QString>::fromVector(xarray);
painter.drawEllipse(xarray[i].toInt(), 10, 100, 100);
}
}
I didn't actually compile that, hope it works and you get the idea.