This is what I'm doing in the Nail LineChart chart for a class work, I'm having a lot of difficulties with the C ++ language, in a certain part of the code I pass by a QVector<QPoint>
parameter, and I want to paint on the DrawLine
function these points, but for this I thought that copying the QVector<QPoint>
that I send to the method, for a QVector<QPoint>
of the class but I can not copy, does anyone give me a help?
#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!";
}