[Qt-interest] Does QMainWindow::setCentralWidget(QWidget *) destroy the old central widget?

Murphy, Sean M. sean.murphy at gd-ais.com
Fri Feb 27 20:49:15 CET 2009


I think the original responder made a typo, it's not QWidgetStack
(there's no such thing in Qt 4).  It's called QStackedWidget.

And a QStackedWidget does NOT allow the user to control which widget to
use.  You as the developer control how the user gets from one widget in
the stack to the next.  Maybe you see the arrows for a QStackedWidget
when you  use one in Designer?  Those don't exist in the real widget,
they are just there for you, the developer, to flip between pages to
populate each page.

Sean

-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Kermit Mei
Sent: Friday, February 27, 2009 2:02 PM
To: Matt Rogers
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Does QMainWindow::setCentralWidget(QWidget *)
destroy the old central widget?

Matt Rogers wrote:
> On Friday 27 February 2009 12:03:10 Kermit Mei wrote:
>   
>> Hello, I have more then three Widgets, and they monopolizes the whole
>> MainWindow  separately during different duration.
>> My idear is to use setCentralWidget() set them as central widget of
the
>> MainWindow when I need.
>>
>> The widgets are QWidget's sub-classes, and they are all controlled as
>> pointer. When I set another widget as central widget of the
mainwindow,
>> I found that the old Central Widget will be destroyed automatically.
>>
>> Is there any better way to do it?
>>
>> Thanks.
>>
>>     
>
> Use a widget stack, set it as the central widget and then use the
widget stack 
> functionality to switch between your three main widgets. See the API
docs for 
> QWidgetStack for more information.
>   
QWidgetStack allow the usrs to choose which Widget to use, but I
don't want it. If the user want to show another widget, he must
complish all the works on the current widget, or press "Return" button.


> Hope this helps.
>   

_______________________________________________
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