Parent-child closing windows in pyside6
-
Hi Group,
We have the following problem, we are develoments a desktop application, that open windows in modal form in series.
LoginApp -> MainMenu -> MainTreeMenu -> KSecOption -> RoleMainWindow -> RoleDefinitionAdd
The application works fine, when windows are open, but the problem is when you close the windows; when RoleDefinitionAdd is closed it return to its parent RoleMainWindow, and when RoleMainWindow is closed, it return to Taskbar (of windows11) instead of return to KSecOpion.
However, if RoleDefinitionAdd is not opened, then the application works fine, I mean, when you open till RoleMainWindow, and the close it, it return to KSecOption, then return to MainTreeMenu this to MainTreeMenu this to MainMenu this return to LoginApp, and finally exit from the application.
Her part of the source
class LoginApp(QMainWindow, LoginUser_v):
def init(self, ctx, parent = None):
super().init(parent)
....
def start_app(self):
self.window = MainMenu(self.ctx,'ksec')
self.window.showMaximized()
self.window.show()class MainTreeMenu(QMainWindow, Menu_v):
def init(self, ctx, appname,parent = None):
super().init(parent)class KSecOption(QMainWindow, Menu_v):
def init(self, ctx, pgm_option,parent = None):
super().init(parent)
self.ctx = ctx
print('opcion menu',pgm_option,parent)
window = eval(pgm_option) #Open RoleMainWindow
window.setWindowModality(Qt.WindowModal)
window.show()class RoleMainWindow(kSecurityMain_v):
def init(self, ctx, parent = None,mdi_area=None):
super().init(parent)
...
def add_role(self):
window = RoleDefinitionAdd(self.ctx, self, self.find_roles_table)
window.show()Can someone help me? Any reading material or examples? please, this driving me crazy
-
Hi,
From the top of my head: opening widgets upon opening widgets within a constructor is usually bad design.
Even more when the window variable is local to the function.
I would recommend properly building your widgets and only after that start your business logic and have proper functions that will create and further show these widgets.