Custom widget: Create a complex widget that provides a layout for use in the form editor

I am trying to create a custom widget plugin (as described here ) that will provide some set of controls along with a container, a layout that I would like to open to the QT Creator form editor.

In my widget plugin interface, I modify the isContainer () function to return true.

bool MyWidgetPlugin::isContainer() const
{
    return true;
}

And the column of the Object Inspector class for this custom widget user file looks something like this:

- QWidget       <- The Custom Widget
| - QPushButton
| - QWidget     <- This is the widget who layout I'd like to expose to the form editor.

This allows me to transfer new widgets to my custom widget in the form editor, but does not apply to the layout. Recently added widgets can be removed on top of other widgets, including those embedded in the custom widget, and I cannot change the layout of the custom widget.

Obviously, the form editor does not currently know that the internal widget is designed to provide the layout, but I'm not sure how to do this, and could not find examples of a custom widget that acts like a container. I looked at the Container Extension Example , but it clearly states that it is for multi-page widgets, so I am convinced that there is a better solution for what I am trying to achieve.

, , -?


: , , . , .

, . , , . , .

+4

Source: https://habr.com/ru/post/1676068/


All Articles