Reputation: 630
My Code:
Ui_startscreen.setupUi(self,self.areaplace)
self.FRAME_BUTTON.mousePressEvent = self.open_sec_view;
def open_sec_view(self,e):
Ui_sec.setupUi(self,self.areaplace);
Okey and now I have three python files, first -> start-program.py, second -> main.py, third -> secview.py
start-program.py is base QT GUI file with blank frame -> self.areaplace when program start self.areaplace include Ui_startscreen(main.py). During the click Ui_startscreen -> self.FRAME_BUTTON I need remove self.areaplace layout and clear view but when I'm using:
self.horizontalLayout.deleteLater()
self.areaplace.findChild(QtGui.QWidget).deleteLater()
console return me this error:
QLayout: Attempting to add QLayout "" to QWidget "secview", which already has a layout
I know I must to delete/remove layout but I don't know how :/ When I comment horizontalLayout every works fine but I have a lot of files and I need to use function to delete layout Can you help me ? :)
Upvotes: 0
Views: 5640
Reputation: 83
The best decision that I found on this problem is to have the one Layout e.g. mainlayout = QHBoxLayout()
. As kind of Layout-conteiner. Then you self.setLayout(mainlayout)
. Then you can do things like self.layout().addLayout(whateverlayoutyouwantedtoseehere)
and when you need to change just do
self.layout().takeAt(0)
and self.layout().addLayout(anotherlayoutyouwantedamomentlater)
. There may occure necessity in recursive destroying your previous layout, it can be done like that
Upvotes: 1