Im trying to make custom widget in Qt with Qwt extension via Add >> New Item >> Qt Class. My enviroment :
- Visual studio 2022
- Qt 5.12.2
- Qwt 6.2.0
- Qt Creator 6.4.0
I successfully executed custom widget with QLabel base class but I can't successfully use QwtPlot class. I get this type of error:
I tried to find digestible answer but there is only something with moc_ files for Qwt. I added those in include file, but nothing works.
custom widget class waterlooo.h
#ifndef WATERLOOO_H
#define WATERLOOO_H
#include "qwt_plot_curve.h"
#include <vector>
#include <QwtPlot>
#include "qobject.h"
using std::vector;
class Waterlooo : public QwtPlot
{
Q_OBJECT
public:
Waterlooo(QWidget *parent = nullptr);
~Waterlooo();
void plotujkur(vector<float> x, vector<float> y, int fftecka);
};
#endif
custom widget class waterlooo.cpp
#include "waterlooo.h"
Waterlooo::Waterlooo(QWidget *parent)
: QwtPlot(parent)
{
this->setAutoFillBackground(true);
this->setPalette(Qt::white);
this->setCanvasBackground(Qt::white);
}
Waterlooo::~Waterlooo()
{}
void Waterlooo::plotujkur(vector<float> x, vector<float> y, int fftecka)
{
QwtPlotCurve* curve1 = new QwtPlotCurve;
curve1->setSamples(&x[0], &y[0], fftecka);
curve1->setPen(QColor(Qt::green));
curve1->attach(this);
this->replot();
}