PDA

View Full Version : Parent-child-problems ;)



nupul
5th May 2006, 19:25
hi again. I am facing a funny problem (nothing unusual ;)) I have the following design structure:

parent: Mod_parent (custom Widget)

children of Mod_parent: c1, c2, c3 (custom Widgets)

Mod_parent inherits from QWidget.

c1,c2,c3 also inherit from QWidget.

c1,c2,c3 are declared as children of Mod_parent in main.cpp

Problem is this: The children are to be shown only when their corresponding buttons are clicked in the parent. But however when the application starts, all the children are visible, transparently one above the other!!! :confused:

What do you think could be the problem?

Thanks

Nupul

PS: i could paste the code, but it is well over 700 lines!!! :eek: so let me know which part would you actually want...I have used the standard inheritance practice followed in most Qt progs. ie Mod_parent(QWidget *parent):QWidget(parent) and same with the children

jacek
5th May 2006, 19:31
What do you think could be the problem?
When you show the parent, all of its children are shown too. Either add those children after you show the widget or hide just them.

nupul
5th May 2006, 19:37
When you show the parent, all of its children are shown too. Either add those children after you show the widget or hide just them.

for the first part you mean like this:




mod_parent->show();

c1=new c1(mod_parent);
c2=new......
.
.
.

return app.exec();



and when and where should i hide them?

Thanks

Nupul

jacek
5th May 2006, 19:50
for the first part you mean like this:
Yes, it should be enough.


and when and where should i hide them?
Whenever and wherever you like, just after you invoke the show() method.

nupul
6th May 2006, 17:58
well I did as told and now the above problem is no longer there but a new one has cropped :eek:!!!

The children c1,c2,c2 are all coming as transparent :confused: ??

They had the framelesswindowhint flag enabled, even after disabling it, the children are still coming frameless!

What could be going on??

Thanks

Nupul

jacek
6th May 2006, 18:53
The children c1,c2,c2 are all coming as transparent
What do you mean by "transparent"? Are these c1, c2 and c3 ordinary widgets or windows?

nupul
7th May 2006, 16:00
What do you mean by "transparent"? Are these c1, c2 and c3 ordinary widgets or windows?

Well c1,c2,c3 are all individual windows having the Qt::FramelessWindowHint flag enabled

jacek
7th May 2006, 16:30
Well c1,c2,c3 are all individual windows having the Qt::FramelessWindowHint flag enabled
Did you set the Qt::Window flag? Without it those widgets won't be separate windows.

nupul
7th May 2006, 18:32
Did you set the Qt::Window flag? Without it those widgets won't be separate windows.

I commented it out but otherwise I have the Qt::SubWindow flag enabled...but still i fail to understand, howcome the transparency?:confused:

jacek
7th May 2006, 19:11
but still i fail to understand, howcome the transparency?
Probably because of Qt::SubWindow, which tells Qt that this widget is not a standalone window. What flags did you set?

nupul
9th May 2006, 13:03
Probably because of Qt::SubWindow, which tells Qt that this widget is not a standalone window. What flags did you set?

Actuall none...as in after enabling the Qt::Window flag, i see the widgets in their own window. But after commenting out all the flags, I see the label/buttons etc of the children, but on the background of the parent!! :confused:

Nupul

jacek
9th May 2006, 14:03
after enabling the Qt::Window flag, i see the widgets in their own window.
Is that what you want?


But after commenting out all the flags, I see the label/buttons etc of the children, but on the background of the parent!!
Because you have told Qt to place that widget on its parent --- just like a button or combo box.