PDA

View Full Version : Reuse parts of designer-based qdialog



derda17
26th April 2016, 09:16
Hi,

I've a complex qdialog (DialogA) that was created in Qt Designer. I need to reuse the essential qwidget of it (Section) in another qdialog (DialogB), that was manually programmed without any wysiwyg. My current approach is to extract Section to a own widget in Qt Designer and use this QWidget in DialogA and DialogB. Reimplementing it manually would be quite a hassle. First, is there a better approach to modularize forms?
Second, how do I include the new widget Section into the original DialogA? Is there any way to say "add the widget from this ui-file at that position"? All tutorials for custom widgets I've found so far include manually coded widgets, not ui-file-based widgets.

Best regards,
derda17

anda_skoa
26th April 2016, 11:02
Extracting something that you need multiple times into its own form/class makes a lot of sense.

You can either use a place holder in the containing dialog, e.g. an empty QWidget, and then add the shared component in code, or use the "promote widget" feature.

Cheers,
_