Qt Creating Custom Widget With UI Form

2.2k Views Asked by At

I want to create custom widget with ui form, but if I add ui form to the widget, it is not showing when building widget.

Shortly, I want to add one button and one textedit into a ui form, and create a custom widget with that, is there an example like this, or how do I do it?

1

There are 1 best solutions below

0
On

It is very simple to create your custom widget and add it to your ui form. Just follow this:

1- Create a default Qt Widgets Project width ui form.

2- Right click on youe project in Projects window and click 'Add New'

3- Select 'C++ Class' and click 'Choose...'

4- Enter your custom widget name and select "QWidget" as "Base class" and click "Next' and then 'Finish'.

5- In the form editor, add a Widget to the form and then right click on it.

6- From the popup menu , select "Promote to..."

7- In dialog that is displayed, enter your custom widget name in the "promoted class name" field and click add.

8- Select custom widget from list and click "promote"