[Qt-interest] Does QMainWindow::setCentralWidget(QWidget *) destroy the old central widget?
Kermit Mei
kermit.mei at gmail.com
Fri Feb 27 20:01:38 CET 2009
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.
>
More information about the Qt-interest-old
mailing list