vonCZ
30th April 2009, 18:29
I have an array of data in the main part of my application. I want to use these values to paint a subclassed widget. I've set it up like so:
// mainApp.cpp
QVector<QPoint> points(4000);
for(int a=0; a<4000; a++)
{
points[a].setX( getX_from_elsewhere() );
points[a].setY( getY_from_elsewhere() );
}
ptrSubclassedWidget->draw(points);
// subClassedWidget.h
private:
QVector<QPoint> wellData;
public:
void draw( QVector<QPoint> dataIn);
protected:
void paintEvent(QPaintEvent *pe);
// subClassedWidget.cpp
void subClassedWidget::draw(QVector<QPoint> dataIn);
{
wellData = dataIn;
update();
}
void subClassedWidget::paintEvent(QPaintEvent *pe)
{
// doesn't work for obvious reason: wellData not an *array* of QPoints, but a Vector of QPoints
painter.drawPolyline(wellData, 4000);
}
So, questions:
1. I know how to draw a polyLine based on an *array* of QPoint. How can I do this using a Vector of QPoints?
2. Should I be passing the QVector to draw() by reference?
// mainApp.cpp
QVector<QPoint> points(4000);
for(int a=0; a<4000; a++)
{
points[a].setX( getX_from_elsewhere() );
points[a].setY( getY_from_elsewhere() );
}
ptrSubclassedWidget->draw(points);
// subClassedWidget.h
private:
QVector<QPoint> wellData;
public:
void draw( QVector<QPoint> dataIn);
protected:
void paintEvent(QPaintEvent *pe);
// subClassedWidget.cpp
void subClassedWidget::draw(QVector<QPoint> dataIn);
{
wellData = dataIn;
update();
}
void subClassedWidget::paintEvent(QPaintEvent *pe)
{
// doesn't work for obvious reason: wellData not an *array* of QPoints, but a Vector of QPoints
painter.drawPolyline(wellData, 4000);
}
So, questions:
1. I know how to draw a polyLine based on an *array* of QPoint. How can I do this using a Vector of QPoints?
2. Should I be passing the QVector to draw() by reference?