[Qt-interest] Widget content not showing with parent
Girish Ramakrishnan
girish at forwardbias.in
Sat Oct 24 18:55:33 CEST 2009
Eirik Ulvik wrote:
>
>
> Girish Ramakrishnan skrev:
>> Eirik Ulvik wrote:
>>
>>> Does anyone have a clue why the contents of a widget is shown when i do:
>>> widget->setParent(0); widget->show(). But not if the widget has a
>>> parent. I have this situation and am really puzzled. What might be the
>>> problem. The widget in question shows open gl content that is integrated
>>> with the Coin3D scene graph and SoQt.
>>>
>>>
>>
>>
>> A widget with parent 0 is a top level. If you call show() on it, it
>> becomes visible.
>>
>> A widget with a parent is visible IFF the parent is visible. Calling
>> show() and hide() on this widget only affects visibility if the parent
>> was visible to stat with.
>>
>> Girish
>>
> Thanks for your reply. I am aware of this. I should have pointed out
> that the following code works;
> MyGlWidget *widget = new MyGlWidget(0);
> widget->show();
>
> but this does not:
> QWidget *parent = new QWidget(0);
> MyGlWidget *widget = new MyGlWidget(parent);
> parent->show();
>
Maybe you want to give MyGlWidget some size? If it has a sizeHint() put
it in a layout.
Girish
More information about the Qt-interest-old
mailing list