Qt-interest Archive, January 2008
Custom group boxes in designer toolbox
Message 1 in thread
Hi Everybody,
I have successfully created a custom widget based QScrollArea and used it in the designer following the steps in the documentation.
Now I want to:
- create 20 different group boxes in the designer,
- declare each group box via a QDesignerCustomWidgetInterface and probably also declare a QDesignerCustomWidgetCollectionInterface,
- use different combinations of the group boxes in 300 forms via the designer.
For example, a group box may have a title and contain several checkboxes in a layout. It uses a Q_PROPERTY to control the number of checkboxes and title, etc.
I don't understand the relationship between the createWidget and domXml procedures? When is each of them used?
In this case how do I get the designer's .ui file (containing the group box) into the domXml function?
Do I also have to include a uic generated header to call in createWidget?
Very confused.
Tony Rietwyk
--
[ signature omitted ]
Message 2 in thread
Replying to my own post:
> Sent: Thursday, 17 January 2008 23:32
> Subject: Custom group boxes in designer toolbox
>
> Now I want to:
>
> - create 20 different group boxes in the designer,
> - declare each group box via a QDesignerCustomWidgetInterface
> and probably also declare a QDesignerCustomWidgetCollectionInterface,
> - use different combinations of the group boxes in 300 forms
> via the designer.
>
> For example, a group box may have a title and contain several
> checkboxes in a layout. It uses a Q_PROPERTY to control the
> number of checkboxes and title, etc.
This works OK:
- Create a widget with group box, etc. in designer.
- Modify the .ui file to remove the top level QWidget, thus making the QGroupBox the top level.
- Designer still opens and saves the .ui OK, and UIC converts it.
- Create a class based on QGroupBox.
- Call ui.setupUi as usual in the constructor.
- In the plugin createWidget, just create and return the new class.
- In the plugin domXML, just return the basic geometry example (0,0,100,100).
- Compile the plugin in release mode, copy to the plugins/designer folder.
- Check the plugin loads in designer using help/about plugins.
- Use the group box in other forms - the checkboxes are visible, but cannot be manipulated.
- The forms that use the group box class, only reference the class, and do not include the child check boxes, etc. This is really good, as it will make the forms much smaller!
- The plugin isContainer is returning false. I assume that this function controls whether designer allows drops on the widget.
- I suspect the domXml is only used to create the drag image from the toolbox?
It would be really nice if a troll could provide some more info on the interface routines createWidget, domXml and isContainer beyond the one-liners in the 4.3.1 doco.
Regards,
Tony Rietwyk
--
[ signature omitted ]