Solved Custom Designer plugin and the promote feature
-
Hi
Im testing with the world clock example
http://doc.qt.io/qt-5/qtdesigner-worldtimeclockplugin-example.html
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 -
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:- Comment this out from the
WorldTimeClockPlugin
class:
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface")
- 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_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface") Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) public: WorldTimeClockPluginWidgets(QObject *parent = nullptr) : QObject(parent) { auto widget = new WorldTimeClockPlugin(); widgets.append(widget); widgets.append(widget); } QList<QDesignerCustomWidgetInterface*> customWidgets() const Q_DECL_OVERRIDE { return widgets; } private: QList<QDesignerCustomWidgetInterface*> widgets; };
- Comment this out from the
-
@Chris-Kawa
Thank you!
It works.
Pretty strange to add twice:) -
@mrjj
Forgive my ignorance, but why do you want to promote that particular widget? Isn't promoting fromQWidget
sufficient for most cases? -
@kshegunov
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. -
@mrjj
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 ...
-
@kshegunov
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
adjustment.
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. :)