How do you add a custom widget to a form within the same project in QtCreator



  • Hi I have a single project which contains the main app and a custom widget. How do i add the custom widget to the main app's ui file graphically? i don't know how to make the designer recognize the custom widget.



  • Two ways:

    • promotion (the easy one, you won't see any graphical difference between your custom widget and the parent one, cause it "promises" you only the fact that setupUi method will create a widget of your custom type, and not the original one). In this case, just right-click on your widget, promote it, give your .h header file and the type of your custom widget.

    • writing a component for Qt designer (the long one). In this case, refer to Qt documentation, just look for "Creating Custom Widgets for Qt Designer" in Qt Assistant, or have a look to this example: "Custom Widget Plugin Example":http://doc.trolltech.com/4.6/designer-customwidgetplugin.html

    Tony.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.