How to Add Custom Class to Qt Designer/Edit Layout Outside of Qt Designer
-
I am using VS2015 C++ with Qt 5.11.0 and am using Qt Designer to layout the UI.
In the UI, I have images that are displayed using QLabel. I want the user to be able to click on these images and different actions take place. It seems many people need this functionality and I followed some of the guides, such as: https://wiki.qt.io/Clickable_QLabel for adding it. I now have a new class called Clickablelabel that should do the trick.
Now, how do I s substitute the new class for the existing Qlabels in Qt Designer?
Alternatively, how do I edit the resulting ui files from Qt Designer to specify the new class?Thanks for any help.
-
@pistorinoj
http://www.qtcentre.org/threads/37926-Subclassing-a-widget-created-in-Qt-DesignerCode your derived class. Use the promotion feature in Designer to make the existing label an instance of your sub-class. The promotion dialog can be found on the right-click context menu in Designer.
is from a while ago, but if it still works sounds like what you want...
Also https://stackoverflow.com/questions/37454998/subclassing-widgets-in-qt-designer
-
That appears to be it.
Thanks