Ok, I tried to help out here by creating a trivial example, but I seem to have a problem of my own! Here is the example:
================================================== from PyQt4 import QtCore, QtGui class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.textEdit1 = QtGui.QPlainTextEdit() self.textEdit1.setPlainText("Text Editor #1") self.textEdit2 = QtGui.QPlainTextEdit() self.textEdit2.setPlainText("Text Editor #2") self.setCentralWidget(self.textEdit1) self.createActions() self.createToolBars() def createActions(self): self.edit1Act = QtGui.QAction(QtGui.QIcon(), "&Editor-1", self, shortcut=QtGui.QKeySequence.New, statusTip="", triggered=self.centralizeEdit1) self.edit2Act = QtGui.QAction(QtGui.QIcon(),"&Editor-2", self, shortcut=QtGui.QKeySequence.Open, statusTip="", triggered=self.centralizeEdit2) def createToolBars(self): self.fileToolBar = self.addToolBar("Central Widget Control") self.fileToolBar.addAction(self.edit1Act) self.fileToolBar.addAction(self.edit2Act) def centralizeEdit1(self): self.setCentralWidget(self.textEdit1) def centralizeEdit2(self): self.setCentralWidget(self.textEdit2) if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) mainWin = MainWindow() mainWin.show() sys.exit(app.exec_()) ================================================ 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 >On Wed, Jan 20, 2010 at 9:14 AM, M Chauhan <mrc...@gmail.com> wrote: > Hi Tabish, > > I would like to replace centralwidget of a mainwindow with another widget > which is created separately. > > For. ex. when I click on a button on mainwindow it should replace the > current centralwidget by a new one. > > Please let me know if you need more info. > > Thanks, > Mrugesh. > > > 2010/1/19 tabish--> <tabish_shaikh...@yahoo.com> >> >> can you please describe ur problem in a better way? >> >> Mrugesh Chauhan wrote: >> > >> > Hello all, >> > >> > Have been trying to find solution to one problem. >> > >> > There's a main window. And there's a widget. Let's call this widget --> >> > widget_new. >> > >> > I would like to replace centralwidget of the mainwindow with the >> > widget_new. >> > >> > >> > setCentralwidget by passing widget_new ( generated by designer) doesn't >> > help. >> > >> > Someone must have come across such a problem. Any leads will be helpful. >> > >> > Thanks, >> > Mru >> > >> > _______________________________________________ >> > PyQt mailing list p...@riverbankcomputing.com >> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt >> > >> >> -- >> View this message in context: >> http://old.nabble.com/centrawidget-and-mainwindow-tp27212686p27221899.html >> Sent from the PyQt mailing list archive at Nabble.com. >> >> _______________________________________________ >> PyQt mailing list p...@riverbankcomputing.com >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > > _______________________________________________ > PyQt mailing list p...@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt