PDA

View Full Version : Self contained objects



alfah
4th August 2011, 07:30
hi

Are there any self contained object lin Qt. By ‘self contained’ i mean, those things which can act like a container. I checked out the containers in Qt, but those are linear ones like stack, queue and all. The following is what im trying to achieve.

I have a form with a lot of buttons, images, vertical layouts, horizontal layouts, grid etc etc. All these put together gives me a calender. I want something which can hold all of these and be able to pass it to another form. If this class ie CalenderForm can return a layout or somethin which i can use it in another form.

I dont know if this is possible. but is there anything close to what im trying to achieve????

alfah

stampede
4th August 2011, 08:14
I want something which can hold all of these and be able to pass it to another form.
This "something" is called QWidget. You can create your CalendarForm as custom QWidget with all those buttons, layouts etc.

If this class ie CalenderForm can return a layout or somethin which i can use it in another form.
You can create one instance of this class and add it to a layout, remove from layout, add to another layout etc. This class don't need to return anything, the class is a "container" itself.

alfah
4th August 2011, 08:49
This is what im trying to achieve
*- I will have a mainTab form with a class. The form would have jus have 3 tabs, Calender, History and Statistics.
*- My project already has three forms with 3 classes CalenderForm, HistoryForm and StatForm.
*- Opening each form in each tab looks like bad GUI programming,so i was thinking if these three forms/classes can give some kinda container/layout with all the widgets, May be then i can put these into each tab in the mainform.

atleast a work around would do.
alfah

stampede
4th August 2011, 09:13
Opening each form in each tab looks like bad GUI programming
What do you mean by "opening each form in each tab" ? Does each tab have a custom widget placed on it (eg. by using "Promote to...") ?

if these three forms/classes can give some kinda container/layout with all the widgets
I'm not sure I understand. You can create a custom QTabWidget-based class for this, in which you create three tabs, each having a custom QWidget-based class added (calendar, history, stats).

SixDegrees
4th August 2011, 11:28
I agree with stampede. If you want a single widget that contains a set of tabs which in turn hold your more specific widgets, then build one. I generally don't like to decompose a GUI this way, but there's nothing stopping you from doing so.

wysota
4th August 2011, 19:05
hi

Are there any self contained object lin Qt. By ‘self contained’ i mean, those things which can act like a container. I checked out the containers in Qt, but those are linear ones like stack, queue and all. The following is what im trying to achieve.

I have a form with a lot of buttons, images, vertical layouts, horizontal layouts, grid etc etc. All these put together gives me a calender. I want something which can hold all of these and be able to pass it to another form. If this class ie CalenderForm can return a layout or somethin which i can use it in another form.

This "something" is called QVariant but I have no idea what you want to use it for, even after reading through this thread. Since widgets can't be copied, you can't say "here you go, make me two copies of that". You need a proper class with a constructor (or alternatively a factory function) that will create such a set of objects for you.

marcvanriet
8th August 2011, 12:38
Strange,

Someone else asked an identical question. See how-to-interact-with-tabs-in-qt (http://www.qtcentre.org/threads/43734-how-to-interact-with-tabs-in-qt). Maybe some school assignment ?

Anyway, see QStackedWidget-and-QTabWidget-Structure-Advice (http://www.qtcentre.org/threads/36032-QStackedWidget-and-QTabWidget-Structure-Advice) for a solution.

Regards,
Marc