Important: Please read the Qt Code of Conduct -

Custom Designer plugin and the promote feature

  • Lifetime Qt Champion

    Im testing with the world clock example
    and it was successfully loaded and used.

    But, its not possible to use the promote feature?

    So what do i need to do to enable it for the world plugin?
    Assuming its possible with custom plugins.? ( i really hope)
    thank you

  • Moderators

    Yeah, so according to this thread it's quite silly but doable.
    You need a widgets collection with a doubled entry for your widget. In case of the world clock example this would boil down to 2 steps:

    1. Comment this out from the WorldTimeClockPlugin class:
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface")
    1. Implement a collection class and add the widget interface twice (you can put that under the widget interface class):
    class WorldTimeClockPluginWidgets: public QObject,
                                       public QDesignerCustomWidgetCollectionInterface
         Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface")
         WorldTimeClockPluginWidgets(QObject *parent = nullptr) : QObject(parent)
            auto widget = new WorldTimeClockPlugin();
         QList<QDesignerCustomWidgetInterface*> customWidgets() const Q_DECL_OVERRIDE
         { return widgets; }
         QList<QDesignerCustomWidgetInterface*> widgets;

  • Lifetime Qt Champion

    Thank you!
    It works.
    Pretty strange to add twice:)

  • Moderators

    Forgive my ignorance, but why do you want to promote that particular widget? Isn't promoting from QWidget sufficient for most cases?

  • Lifetime Qt Champion

    its allows me to play with a dedicated promotion widget that show image and other info.
    I could use QLabel etc but would like a custom one.

    Main reason is that a normal QWidget dont show any sign of promotion.
    I would like show more and/or color to provide more design
    feedback in Designer.

  • Moderators

    Fair enough, I was just curious. :)

    Also I believe promotion doesn't allow you to fiddle with the properties, so you'd like to be as close as possible to the end-result widget ...

  • Lifetime Qt Champion

    its not so much to be able to set properties design time.
    More for the visual feedback while layout out the GUI.
    It seems that dynamic properties carry over so
    that could also be used for design time
    Its just a research project. Might be lame idea.

    But I needed to be able to promote to even be possible.

    Ill let u know if it was it fact pointless or it did provide benefits.
    I still need to test if a custom widget can get the other widget on the form at design time.
    That would open up for interesting stuff. :)

Log in to reply