0

I have created a plugin which is a gauge. I used QQuickWidget to create the plugin. This is my plugin definition class and it works perfectly and will be added to QtCreator components:

class QDESIGNER_WIDGET_EXPORT AnalogeGauge : public QQuickWidget
{
    Q_OBJECT
    Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged)
    Q_PROPERTY(double min READ min WRITE setMin NOTIFY minChanged)
    Q_PROPERTY(double max READ max WRITE setMax NOTIFY maxChanged)
public:
    AnalogeGauge(QWidget *parent = nullptr);

    double value() const;
    void setValue(double value);

    double min() const;
    void setMin(double min);

    double max() const;
    void setMax(double max);

signals:
    void valueChanged(QVariant val);
    void minChanged(QVariant val);
    void maxChanged(QVariant val);

private:
    double _value;
    double _min;
    double _max;
};

After designing my ui with this plugin, I want to convert the .ui to .py. But after using pyuic5 to convert and run the python file, I'll face following error:

  File "ui_form.py", line 44, in <module>
    from analogegauge import AnalogeGauge
ModuleNotFoundError: No module named 'analogegauge'

So it seems the plugin is not added. My question is how to fix this error or how can I convert the plugin also to .py? thanks

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Mosi
  • 1,178
  • 2
  • 12
  • 30
  • If it has been shown in the Qt Designer then if the plugin has worked, but one thing is the plugin and another thing is the binding of your class in python, and for this you could use SIP – eyllanesc Aug 02 '19 at 08:52
  • Yeah it shows on qtdesigner but returns error on py – Mosi Aug 02 '19 at 09:01
  • The plugin only works for Qt Designer and nothing else. But if you want to use it in Python then you must do a binding as PyQt5 or PySide2 does, and for this you can SIP or shiboken, respectively. See this example: https://github.com/eyllanesc/Qt5toPyQt5 – eyllanesc Aug 02 '19 at 09:02

0 Answers0