[Qt-interest] Organize Qt Designer UI objects in hierarchy

John McClurkin jwm at nei.nih.gov
Tue Jul 6 21:03:28 CEST 2010


Dr. X wrote:
> Hi All,
> I am using Qt Designer to design a GUI with objects embedded in another 
> object. For instance, I have both a QSlider and QDateEdit in a QGroupBox 
> to control the date of the start of an event. And another pair of 
> QSlider and QDateEdit in another QGroupBox for the end date of the same 
> event. Through Qt Designer, all the objects are flat, i.e.
> QGroupBox* groupBox_startDate;
> QSlider* slider_startDate;
> QDateEdit* dateEdit_startDate;
> 
> QGroupBox* groupBox_endDate;
> QSlider* slider_endDate;
> QDateEdit* dateEdit_endDate;
> ....
> 
> I would like some how to organize them as
> struct DateControl{
> QGroupBox* groupBox;
> QSlider* slider;
> QDateEdit* dateEdit;
> };
> 
> It is conceptually straightforward and easier to maintain the code 
> especially the coupled signal/slot actions with each object group.
> Can anyone suggest how I can do so through Qt Designer? Since every time 
> I modify the .ui file, I will have a new UICed .h file. This is quite 
> annoying when you want to rely on Qt Designer to iterate through a 
> project development. Thanks a lot.
> 

Create a single GUI class with the three elements. Then, when you want 
to instantiate this control, place the base widget in QtDesigner and 
promote it to your class.



More information about the Qt-interest-old mailing list