How to show form (own class) called in a hidden MainWindow class?

29 Views Asked by At

I try to implement a login form. Until now, I've set the Login-Dialog seperately from the MainWindow:

current_user = current_user()
login_form = Loginpage(df_benutzer, current_user)
form.show()
window = MainWindow()

I do not show the window, this is realized in the Login-class. I don't like it very much, because I need to store the current_user to use in different classes etc. So my idea was, to define the login_form within the MainWindow-Class at the very begining of the init:

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self, parent = None):
        super().__init__(parent)
        self.current_user = current_user()
        form = Loginpage(df_benutzer, self.current_user)
        form.show()
        self.ui = modulevar.Ui_MainWindow()
        self.ui.setupUi(self)
        
        ...

If the login is OK, the Loginpage-class is calling window.show(). But this doesn't work: the Form is never showed. How do I need to change my way?

Thanks a lot in advance for your help! Regards, Stefan (no software designer but I love to code my own apps :))

  • tried to run it with window.hide() in Loginpage/MainWindow. But window was unknown (what's clear if I write it down: during initialisation the object does not yet exist)

  • tried to override the show-method in MainWindow. But that wasn't a good idea: caused massive count of error-messages

0

There are 0 best solutions below