I am loading a QMainWIndow base from a *.ui file. Also, i have a custom widget i want to place somewhere on the form. Currently i put in the .ui file an empty QVBoxLayout named placeholder, and in the QMainWindow subclass do self.placeholder.addWidget(my_custom_widget)
The only thing i don’t like in this approach is that the empty layout does not have its own size. I can have a layout with one cell and with a dummy widget (QLabel for example) with the size i want, and replace this widget and then add my custom widget, but the method seems too much for me.
What is your approach for such a task?
I am using Python (PyQt4)
Here is an easy little tutorial on how to promote a widget:
QWidgetin this case.MyWidgetMyWidgetis placed.Promote. You are done promoting.QWidget, it’sMyWidgetinstead.In the file at
/path/to/MyWidget.pyI have a class namedMyWidget, and the content is something like this: