PDA

View Full Version : How to create customDesignerWidget with functional QBoxLayout



PetriJ
30th April 2016, 22:37
Hi,
I have a customDesignerWidget that inherits from QGroupBox. Inside the groupBox I have a QVBoxLayout.
By default when you do this, you can not interact with the QVBoxLayout, meaning that you can not drag any widgets to it in designer because the designer only sees the customDesignerWidget plugin.

Any ideas how I could give access to the QVBoxLayout so that when the user drags a widget over this custom designer widget, the widget would be added to the QVBoxLayout?

Thanks

PetriJ
2nd May 2016, 16:14
Found the answer and it was embarrissingly simple.
Just add this to the domXml function in the subclassed QDesignerCustomWidgetInterface.

<layout class='QVBoxLayout' name='verticalLayout_2'></layout>

Note:
If you add a layout as a private member and then set the layout to the widget, this method does not work if you want the layout to be functional in the designer.