Search code examples
qtcustom-controlsqt-creatorqt-designerqwidget

How to use custom widget in Qt-Designer


I want to use a custom widget in the GUI-Designer of Qt-Creator IDE. So i created a class which inherits from Qt's QWidget. It worked to place it on a QMainWindow programaticaly, but have to do my work in the desiger where it does not appear as an option in the kist of components.

I googled to find a solution for problem an found an manual on, who guesses, the Qt doc page ( https://doc.qt.io/archives/qt-4.7/designer-creating-custom-widgets.html and https://doc.qt.io/archives/qt-4.7/designer-creating-custom-widgets.html). I tried to follow it but doesn't work.

Does someone know an other way to do this or can give a hint where i can search for problems following this tutorial?

Thanks in advance.

Codierknecht


Solution

  • There is a different example in the examples section of the Qt documentation that I think is a lot clearer.

    Custom Widget Plugin Example

    It was a little unclear to me when reading the tutorial where the Q_EXPORT_PLUGIN2() macro goes, but having full example code and project alleviates that.