Qt Custom control. Problem with Q_PROPERTY() and QConicalGradient
-
Hello,
I am trying to build a custom Widget/plugin. I have everything set up. I am using qt 5.12.1 with creator 4.8.1
- I can build my plugin and generate so file
- Copy my so file to /home/rob/qt_plugin/designer/
- export QT_PLUGIN_PATH=/home/rob/qt_plugin/
- Start Qt Creator from a terminal and open simple empty test application
- Drag my control from creator toolbar to the main canvas and run my application.
So everything is ok so far. The problem is as step 5 when I drag it to a canvas I see an error in the terminal in which I started qt creator. The error is generated when I drop my control. Here is the error:
The property "powGrandient" of type (unknown) is not supported yet!
Here is stripped down version of my header that I am using to test this
// H Source #include <QWidget> #include <QConicalGradient> #include <QtUiPlugin/QDesignerExportWidget> Q_DECLARE_METATYPE(QConicalGradient) class QDESIGNER_WIDGET_EXPORT GradMeter : public QWidget { Q_OBJECT Q_PROPERTY(QConicalGradient powGrandient READ powGradient WRITE setPowGradient) public: explicit GradMeter(QWidget *parent = nullptr); const QConicalGradient& powGradient() const { return _gradient; } void setPowGradient(const QConicalGradient &gradient) { _gradient = gradient; } private: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: QConicalGradient _gradient; };
Here is my cpp
GradMeter::GradMeter(QWidget *parent) : QWidget(parent) { _gradient = QConicalGradient(0, 0, 180); _gradient.setColorAt(0, Qt::red); _gradient.setColorAt(0.2, Qt::yellow); _gradient.setColorAt(0.8, Qt::green); } void GradMeter::paintEvent(QPaintEvent *) { // Some drawing code here QPainter painter(this); }
So from my research, I found out that if I and trying to use my custom class I would have to do little extra coding with QDesignerPropertySheetExtension to describe to Qt creator property editor how my custom class looks like.
But this is not the case since I am trying to use Qt building class from QConicalGradient from qbrish.hLooking at QConicalGradient class see it is derived from QGradient which is missing Q_ENUM(InterpolationMode). All other enums in this class do have QENUM() for it. Is this the problem?
Anyone can point me how to fix this problem?
Thank you in advance.