Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Navigation between interface in PyQt5 and python
QtWS25 Last Chance

Navigation between interface in PyQt5 and python

Scheduled Pinned Locked Moved Unsolved General and Desktop
pyqt5formnavigationfunctionsevents
6 Posts 3 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lanas
    wrote on last edited by lanas
    #1

    I'am new to PyQt and i faced a problem i want to navigate between forms . what i want is : when i click on button to go to an new interface the current one close automatically ( if i am in the Sign In interface and i clicked on a button to go to the Sign up i want the Sing in to close ) but the problem i face the function does not work both of the interface still open,i tried to add MainWindow.hide() function does not work and i got an error witch is Error! Error due to 'Ui_Login_Dialog' object has no attribute 'hide'

    this is my function

        def openwindow(self):
          try:
            self.nextui = QtWidgets.QWidget()
            self.ui = Registration.Ui_Registration()
            self.ui.setupUi(self.nextui)
            self.nextui.show()
        
    

    this is what the function give me

    (Capture.PNG

    JonBJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      That's because you should call hide on the widget that you initialised Ui_Login_Dialog with.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        That's because you should call hide on the widget that you initialised Ui_Login_Dialog with.

        L Offline
        L Offline
        lanas
        wrote on last edited by lanas
        #3

        @SGaist
        i watched many tutorials and response from other forum , they use .hide() as predefined method so i do not know how to call hide
        if you mean that MainWindow should be the name of the current windows ,yes it is the name of it
        i generate the code using pyuic
        this is my function

        self.nextui = QtWidgets.QDialog()
               self.ui = Ui_Model_list()
               self.ui.setupUi(self.nextui)
               self.nextui.show()
               MainWindow.hide()
        
        1 Reply Last reply
        0
        • L lanas

          I'am new to PyQt and i faced a problem i want to navigate between forms . what i want is : when i click on button to go to an new interface the current one close automatically ( if i am in the Sign In interface and i clicked on a button to go to the Sign up i want the Sing in to close ) but the problem i face the function does not work both of the interface still open,i tried to add MainWindow.hide() function does not work and i got an error witch is Error! Error due to 'Ui_Login_Dialog' object has no attribute 'hide'

          this is my function

              def openwindow(self):
                try:
                  self.nextui = QtWidgets.QWidget()
                  self.ui = Registration.Ui_Registration()
                  self.ui.setupUi(self.nextui)
                  self.nextui.show()
              
          

          this is what the function give me

          (Capture.PNG

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @lanas said in Navigation between interface in PyQt5 and python:

          if i am in the Sign In interface and i clicked on a button to go to the Sign up i want the Sing in to close

          ,i tried to add MainWindow.hide() function

          Hiding the MainWindow is not the thing to do if you are wanting to hide the Sign In dialog!

          @SGaist said in Navigation between interface in PyQt5 and python:

          That's because you should call hide on the widget that you initialised Ui_Login_Dialog with.

          What widget did you initialise Ui_Login_Dialog with? Since I see no mention of Ui_Login_Dialog I cannot tell. I cannot have no idea what either Registration.Ui_Registration() or Ui_Model_list() are, only you know.

                  self.ui = Registration.Ui_Registration()
                  self.ui.setupUi(self.nextui)
                  self.nextui.show()
          

          If the dialog you want to hide/close is the self.nextui here then you will want self.nextui.hide() just as you have self.nextui.show().

          L 1 Reply Last reply
          1
          • JonBJ JonB

            @lanas said in Navigation between interface in PyQt5 and python:

            if i am in the Sign In interface and i clicked on a button to go to the Sign up i want the Sing in to close

            ,i tried to add MainWindow.hide() function

            Hiding the MainWindow is not the thing to do if you are wanting to hide the Sign In dialog!

            @SGaist said in Navigation between interface in PyQt5 and python:

            That's because you should call hide on the widget that you initialised Ui_Login_Dialog with.

            What widget did you initialise Ui_Login_Dialog with? Since I see no mention of Ui_Login_Dialog I cannot tell. I cannot have no idea what either Registration.Ui_Registration() or Ui_Model_list() are, only you know.

                    self.ui = Registration.Ui_Registration()
                    self.ui.setupUi(self.nextui)
                    self.nextui.show()
            

            If the dialog you want to hide/close is the self.nextui here then you will want self.nextui.hide() just as you have self.nextui.show().

            L Offline
            L Offline
            lanas
            wrote on last edited by
            #5

            @JonB
            the Ui_Model_list() is the name of the next interface and MainWindow is the current window
            the dialog i want hide is MianWindow but the function hide did not work it gives me an error (Error due to 'MainWindow' object has no attribute 'hide')
            so as conclusion the next window is showing up but the first Window does not close or hide even i use close() i still face the same problem

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Interface is the keyword here: interface != widget.

              You build a widget with the interface you defined but the interface itself is not a widget.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved