[Qt-interest] Adding a QSpacerItem makes other widgets disapper...
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Tue May 25 16:59:45 CEST 2010
Kustaa,
Do your custom widgets (InputPane, etc) return a valid size hint?
It may also help to set the sizing policies, min sizes, etc.
Use QLayout.count and .itemAt to get the layout items - not
QObject.children.
Tony.
> -----Original Message-----
snip
> MyView is derived from QWidget, and so are CalibrationPane,
> OutputPane and
> InputPane. Each of them also has a .ui form.
>
> The above code works I get eg three panes nicely laid out
> vertically thanks
> to 'new QBoxLayout(QBoxLayout::TopToBottom, this)' in the MyView
> constructor.
>
> However, as soon as I uncomment the last line, the all the
> widgets that re
> created int the while loop disappear. But I I add for example
> QPushButton's
> before and/or after the 'addItem(new QSpacerItem' those are displayed
> correctly.
>
> So my thinking is that this is some sort of
> layout/hint/constraint issue but
> I'm at lost on how to debug this.
>
> I tried to display the widget as follows:
>
> QObject* t;
> QObjectList list = layout()->children();
> foreach (t , list) {
> QLayoutItem* item=reinterpret_cast<QLayoutItem*>(t);
> qDebug() << "***" << item->geometry();
> }
>
> But the list seems to be empty, regardless if the widgets are
> displayed correctly or not.
>
> br Kusti
More information about the Qt-interest-old
mailing list