View Full Version : Parent-child-problems ;)
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
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.
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
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.
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
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?
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
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.
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:
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?
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
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.