[Qt-interest] change centralwidget in qtcreator

Robert Escott robert at binarylogic.co.za
Wed Apr 27 21:02:02 CEST 2011


There is no need to explicitly delete the current centralWidget. As the
documentation states, the QMainWindow takes ownership of whatever
QWidget you supply to the QMainWindow::setCentralWidget function. This
means that it takes the responsibility of deleting it. As at the current
version of Qt (4.7.x), as soon as you set a new centralWidget, the old
one gets deleted. Make sure you don't have any static references
somewhere that could cause a double-deletion error later.

On 27/04/2011 19:11, Yuvraaj Kelkar wrote:
> Use QMainWindow::setCentralWidget
> http://doc.qt.nokia.com/4.7/qmainwindow.html#setCentralWidget
>
> Delete the original central widget and later when using the new
> central widget that you saved, make sure you typecast it properly.
>
> 2011/4/27 zhao_yunsong <zhao_yunsong at 163.com>:
>> I want to change the centralwidget (which is a instance of QWidget by
>> default) of a mainwindow program in qtcreator, how can i do this.
>>
>>
>>
>>
>> 2011-04-28
>> ________________________________
>> zhao_yunsong
>> ________________________________
>> 发件人: qt-interest-request
>> 发送时间: 2011-04-28  00:54:56
>> 收件人: qt-interest
>> 抄送:
>> 主题: Qt-interest Digest, Vol 5, Issue 127




More information about the Qt-interest-old mailing list