[Qt-interest] update contents of QWidget
Dr. X
xunlei at renci.org
Thu Jun 3 15:01:29 CEST 2010
Thanks, John. That is what I did. I was wondering whether there is an
existing mechanism of just calling parent's, say show(), then all its
children show() are triggered, unless they are explicitly hidden. I
guess I can subclass Qwidget class and add
=======
void MyWidget::show()
{
QWidget::show();
emit showAllChildren();
}
...
connect(MyWidget, SIGNAL(showAllChildren()), QPushButton, SLOT(show()));
======
I don't want to reinvent the wheel if such top-down triggering already
exists in Qt. As I noted, if I create all the child objects before the
main loop starts, calling parent's show() will automatically bring up
the children without calling child->show().
Thanks a lot.
Best,
x
On 6/3/2010 8:38 AM, John McClurkin wrote:
> Dr. X wrote:
>
>> Thanks, Nikos.
>> It works! But is there a mechanism of calling a top level function to
>> show/hide all the children objects?
>> Appreciate your help.
>> Best,
>> x
>>
> Put all of the children in a single parent widget that is a child of
> QMainWindow. Call show() on each child, then call show() on the parent.
>
>
>> On 6/2/2010 11:15 PM, Nikos Chantziaras wrote:
>>
>>> On 06/03/2010 06:05 AM, Dr. X wrote:
>>>
>>>
>>>> Hi All,
>>>>
>>>> I would like to dynamically add a set of QPushButton objects in a
>>>> QWidget object after the program is in the main .exec() loop. The data
>>>> hierarchy is like this:
>>>> QMainWindow -> QWidget -> QPushButton
>>>> ...
>>>> -> QPushButton
>>>> I know how to create and position QPushButton objects in a QWidget
>>>> object before QMainWindow::show(). But after the program enter the main
>>>> loop, any newly created objects under that QWidget are not shown. I
>>>> checked out the painter example. But that is not what I want. Would you
>>>> please help? Thanks a lot.
>>>>
>>>>
>>> I assume the QWidget has been made the central widget with
>>> QMainWindow::setCentralWidget(). In that case, anything you add to the
>>> central widget must be shown explicitly. In your case,
>>> QPushButton::show().
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>
>>>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list