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. PyQt QMainWindow
Forum Update on Monday, May 27th 2025

PyQt QMainWindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 311 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.
  • H Offline
    H Offline
    henry5059
    wrote on 6 Feb 2021, 04:31 last edited by
    #1

    Good, please, how do I open a single instance of a QMainWindow ?, that is, only when there is no instance of that type of QMainWindow.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Feb 2021, 07:26 last edited by
      #2

      Hi and welcome to devnet,

      As silly as it may sound: create it only once.

      For a more complete answer, please provide more details about your use case.

      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
      1
      • H Offline
        H Offline
        henry5059
        wrote on 6 Feb 2021, 13:15 last edited by
        #3

        Example: I have three classes that inherit from QMainWindow called: UnityIndex, ArticleIndex and InvoicingIndex, I want a single instance of each class to be executed, that is, the instance is executed only when it is not active and if it is already active, do not execute a new instance, and that allows me to execute the three classes but with a single instance.

        J 1 Reply Last reply 6 Feb 2021, 13:43
        0
        • H henry5059
          6 Feb 2021, 13:15

          Example: I have three classes that inherit from QMainWindow called: UnityIndex, ArticleIndex and InvoicingIndex, I want a single instance of each class to be executed, that is, the instance is executed only when it is not active and if it is already active, do not execute a new instance, and that allows me to execute the three classes but with a single instance.

          J Offline
          J Offline
          JonB
          wrote on 6 Feb 2021, 13:43 last edited by
          #4

          @henry5059
          You can't. Also, you don't "execute classes, or even instances of classes". So "allows me to execute the three classes but with a single instance" doesn't mean a lot to me.

          Purely at a guess, perhaps you are talking about needing a QStackedWidget so as to show only one widget at time from among multiple widgets.

          Separately, why you would want to have more than one instance of a QMainWindow anywhere in your program I do not know. Usually you are best with one main window, nothing else needs to have QMainWindow style.

          H 1 Reply Last reply 6 Feb 2021, 13:57
          1
          • J JonB
            6 Feb 2021, 13:43

            @henry5059
            You can't. Also, you don't "execute classes, or even instances of classes". So "allows me to execute the three classes but with a single instance" doesn't mean a lot to me.

            Purely at a guess, perhaps you are talking about needing a QStackedWidget so as to show only one widget at time from among multiple widgets.

            Separately, why you would want to have more than one instance of a QMainWindow anywhere in your program I do not know. Usually you are best with one main window, nothing else needs to have QMainWindow style.

            H Offline
            H Offline
            henry5059
            wrote on 6 Feb 2021, 13:57 last edited by
            #5

            @JonB Okay, thanks for the info

            1 Reply Last reply
            0

            1/5

            6 Feb 2021, 04:31

            • Login

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