[PyQt] centrawidget and mainwindow

David Boddie david at boddie.org.uk
Thu Jan 21 01:01:28 GMT 2010


On Wed, 20 Jan 2010 10:46:10 -0800, Jamie Riotto wrote:

> When I run this, it correctly sets Text Edit #1 as Central Widget.
> Pressing "Editor-2" button correctly changes the Central
> Widget to Text Edit #2, however, when I press "Editor-1" button to
> restore Text Edit #1 to Central Widget I get:
>
> RuntimeError
> "underliying C/C++ object has been deleted"
>
> Any clues as to what I'm doing wrong??? Thanks - jamie

Qt deletes the existing central widget behind the scenes when you set a
new one:

  http://qt.nokia.com/doc/4.6/qmainwindow.html#setCentralWidget

If you want to use multiple reusable widgets, put them in a QStackedWidget
and set that as the central widget.

David


More information about the PyQt mailing list