1
Here’s what I’m doing in the nail a Linechart chart chart for a class assignment, I’m having huge difficulties with the C++ language, in some part of the code step by parameter a QVector<QPoint>
, and I want to paint in function DrawLine
these points, but for that I thought that copy the QVector<QPoint>
I send to the method, to a QVector<QPoint>
global class but can’t copy, someone give me a hand ?
#pragma once
#include <QFrame>
#include <QWidget>
#include <QHBoxLayout>
#include <QPaintEvent>
#include <QPainter>
#include <QMainWindow>
#include <QLabel>
#include <QVector>
class LineChart : public QFrame
{
Q_OBJECT
public:
LineChart();
void addSeries(QVector<QPoint> series, QColor color);
void setAxisX(QVector<QString> values);
void setAxisY(QVector<QString> values);
void setLabelX(QString name);
void setLabelY(QString name);
void setTitle(QString title);
void paintEvent(QPaintEvent* paint);
// keyPressEvent(QKeyEvent *event);
private:
//QFrame *frame;
QGridLayout *layout;
QLabel *label;
int x0,x1,y0,y1;
QPoint *point;
QPoint *point2;
QVector<QPoint> *vector;
//QPushButton *button;
};
void LineChart::addSeries(QVector<QPoint> series, QColor color){
vector = new QVector<QPoint>;
vector = series;
}
void LineChart::paintEvent(QPaintEvent *event){
QFrame::paintEvent(event);
QPainter painter(this);
qDebug() << point->rx() ;
qDebug() << point->ry();
qDebug() << point2->rx() ;
qDebug() << point2->ry();
//painter.drawLine(point->rx(),point2->ry(),point->rx(),point2->ry());
for(int i = 0 ; i< vector->length() ; i++){
}
qDebug() << "paintEventinvocado!";
}
You can merely assign one Qvector to the other, by
operator=
. Tried that?– Guilherme Bernal