PDA

View Full Version : QWidegt->show() pops out a new window (windows only)



powlee
5th July 2012, 16:05
Hi,
I discovered a rather strange behavior in my application under Windows. I'm developing an application under Linux and use it on Windows machines also.

I have a GroupBox holding a widget, and hide and show the widget depending on the toggled Slot of the groupBox.
In Linux this works really fine.

In Windows however the widget doesn't show when I start the application. When I click on the checkBox a second time. A new Window containing my widget pops out. I have really no idea how this can happen.
Anyone any advice?

Although I have some experience I'm not sure if this isn't a very noobish mistake and therefore post it in the newbs group.

thx for the help

Code looks something like this:



void myWidget::gbToggled(bool on){
if(on)
otherWidger->show();
else
oderWidget->hide();
}



795979607961

high_flyer
5th July 2012, 16:17
is this widget parented?

powlee
5th July 2012, 16:35
No it was not! Thx, now it doesn't pop out anymore.
It just refuses to show itself at all now. Just a little line under box text if the box is checked.

high_flyer
5th July 2012, 16:39
Well, you have to make sure its not sharing the same space with other widget!
Use a layout.

powlee
5th July 2012, 16:49
I do.
But maybe I'm doing t wrong.



QGridLayout *layout = new QGridLayout();
gbTimePeriod = new QGroupBox(tr("Zeitraumbezogen"));
gbTimePeriod->setCheckable(true);
connect(gbTimePeriod, SIGNAL(toggled(bool)), this, SLOT(gbToggled(bool)));
layout->addWidget(gbTimePeriod, 0, 0);
QGridLayout *lPeriod = new QGridLayout();
cabw = new ContinuousActionBaseWidget(videoPlayer, this);
lPeriod->addWidget(cabw, 1, 0);
gbTimePeriod->setLayout(lPeriod);

high_flyer
5th July 2012, 17:03
you embed your widget inside 'layout', but didn't set 'layout' to any widget.

powlee
5th July 2012, 17:15
True, its not in this part.
the setLayout is at the end of the Constructor. Other widgets are added to the layout as well.

But nevermind I already found the bug, it was just me being extremely stupid. I still had the addWidget in comments on my Windows Machine and posted code from my VBox where i actually work.
I didn't consider that because I was so flubber gusted by the widget popping out.
Anyhow thank you very much for your help and patience, have an awesome day.