Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How should I start a screen?
Forum Updated to NodeBB v4.3 + New Features

How should I start a screen?

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 2 Posters 417 Views 1 Watching
  • 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.
  • _ Offline
    _ Offline
    _jao_victor_
    wrote on last edited by _jao_victor_
    #1

    How do I start a login screen and sequentially a main screen (after data validation) ? I am a beginner and saw that it is not feasible to have two QApplication screens on the same system. However, as I use qtDesigner to develop my GUIs the code that runs my screens is automatically generated:

    if __name__ == '__main__':
        import sys
        app = QtWidgets.QApplication.instance()
        MainWindow = QtWidgets.QMainWindow()
        ui = TelaLogin()
        ui.setupUi(MainWindow)
        MainWindow.show()
        sys.exit(app.exec_())
    

    How do I stop my login screen from being QApplication so that the main screen can run?

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

      The code generated by Designer allows you to see the widget if you call the script directly. That's not what you want.

      Create your own main.py, import the widgets you want to use and implement the logic there.

      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
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        You should do it in two steps. First manage the login using a dialog and only if successful continue with the MainWindow.

        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
        2
        • SGaistS SGaist

          Hi,

          You should do it in two steps. First manage the login using a dialog and only if successful continue with the MainWindow.

          _ Offline
          _ Offline
          _jao_victor_
          wrote on last edited by _jao_victor_
          #3

          @SGaist Now my login screen is a QDialog and my main screen is a QMainWindow. I want to manage these screens through another file (main.py), but I don't know how to start these screens in this file.

          The code generated by qtDesigner generated this screen execution code:

          import sys
              app = QtWidgets.QApplication(sys.argv)
              Dialog = QtWidgets.QDialog()
              ui = Ui_Dialog()
              ui.setupUi(Dialog)
              Dialog.show()
              sys.exit(app.exec_())
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            The code generated by Designer allows you to see the widget if you call the script directly. That's not what you want.

            Create your own main.py, import the widgets you want to use and implement the logic there.

            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