PDA

View Full Version : BUG: adding 5 child-widgets to a widgets layout makes widget invisible



planetLars
18th April 2010, 12:15
See http://www.qtcentre.org/threads/29953-adding-a-QCheckBox-to-a-QLayout-makes-QWidget-not-display-no-matter-how-its-added.

This has nothing to do with the particular child-widget used.

In any order 4 is the maximum number of child widgets a layout can handle (even via sub-layouts or addRow where one row equals one child-widget) before the widget becomes invisible.

So confirmed with Qt 4.6.2 under Windows 7.


See submission at http://bugreports.qt.nokia.com/browse/QTBUG-10008

wysota
18th April 2010, 12:52
You mean this doesn't work?


#include <QtGui>

int main(int argc, char **argv){
QApplication app(argc, argv);
QWidget w;
QVBoxLayout *l = new QVBoxLayout(&w);
for(int i=0;i<10;i++) {
QPushButton *b = new QPushButton(QString::number(i+1));
l->addWidget(b);
}
w.showMaximized();
return app.exec();
}

planetLars
18th April 2010, 13:18
Hi,

this does work. I phrased too general obviously.

I checked other parts of my code. I have 2 QWidget windows. The first accesses the seconds position when the first gets moved. This appears to work as long as there are 4 child-widgets inside. Having 5 leads to the second window being invisible. So it may even be a bug in my code or something I can work around now. I am going to check further with the first window (I stripped the code related to the second window and that "BUG" occurs) and report back.

wysota
18th April 2010, 13:20
Please ask your invisible widget for its geometry. It is possible you just moved it out of the screen boundaries.

planetLars
18th April 2010, 13:44
Hello,

it appears that a void moveEvent(QMoveEvent*) gets fired on void show() and the moveEvent code gets executed before the show code which is where I initialize variables for the second windows position. As the moveEvent uses these variables the second window gets put to some outside random location thus being invisible.

Not a bug after all (except if that event mechansim is unintentional or not wanted). Apparently the randomness of the uninitialized variables is "outside screen" for 5 child-widgets and "inside screen" for 4 child-widgets.

Thank you.

wysota
18th April 2010, 23:31
Not a bug after all
Yeeeay... another one bites the star dust :)

(except if that event mechansim is unintentional or not wanted).
Of course it is intentional.


Apparently the randomness of the uninitialized variables is "outside screen" for 5 child-widgets and "inside screen" for 4 child-widgets.

Not really :)