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. Why Does Minimization Immediately after Show and Activation Cause Non-Minimization?
Forum Updated to NodeBB v4.3 + New Features

Why Does Minimization Immediately after Show and Activation Cause Non-Minimization?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.8k Views 3 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.
  • J Offline
    J Offline
    johnzhou721
    wrote last edited by
    #1

    Subject. See reproducer below in PySide6, but the window is not minimized when the code runs. Any way to work around this issue besides adding a short delay, or am I simply crazy for coming up with mashing together random window state commands to find random bugs in Qt?

    import sys
    from PySide6.QtWidgets import QApplication, QMainWindow
    app = QApplication(sys.argv)
    window = QMainWindow()
    window.setWindowTitle("Test Window")
    window.resize(400, 300)
    window.show()
    window.activateWindow()
    window.showMinimized()
    sys.exit(app.exec())
    

    Thank you!

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

      Hi,

      Which version of PySide6
      On which OS ?
      If Linux:

      • Which distribution ?
      • Which window manager ?

      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
      • J johnzhou721

        Subject. See reproducer below in PySide6, but the window is not minimized when the code runs. Any way to work around this issue besides adding a short delay, or am I simply crazy for coming up with mashing together random window state commands to find random bugs in Qt?

        import sys
        from PySide6.QtWidgets import QApplication, QMainWindow
        app = QApplication(sys.argv)
        window = QMainWindow()
        window.setWindowTitle("Test Window")
        window.resize(400, 300)
        window.show()
        window.activateWindow()
        window.showMinimized()
        sys.exit(app.exec())
        

        Thank you!

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote last edited by JonB
        #3

        @johnzhou721
        I have tried your code under Ubuntu 24.04, GNOME, Xorg, Qt ~6.4.

        I agree that something about the combination of

        window.show()
        window.activateWindow()
        

        (seems to require both) preceding makes window.showMinimized() not minimize. I am not sure what/how it works exactly.

        Putting the showMinimized into a singleShot() makes the minimization work. This is not an uncommon technique in Qt UI code, so if it were ne I would probably accept and live with it, unless there is a pressing reason you do not want to do this.

        I know you are asking about that and window state elsewhere. It is hard to keep tabs on your various separate threads which are really all to do with the same issue.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          johnzhou721
          wrote last edited by
          #4

          Hi @SGaist! Sorry, latest PySide6, Linux, Fedora KDE Spin, X11.

          @JonB Ok... turns out still not minimizing after singleShot... somehow delaying by 100ms works...

          I'm interested in knowing why this happesn.

          Kent-DorfmanK 1 Reply Last reply
          0
          • J johnzhou721

            Hi @SGaist! Sorry, latest PySide6, Linux, Fedora KDE Spin, X11.

            @JonB Ok... turns out still not minimizing after singleShot... somehow delaying by 100ms works...

            I'm interested in knowing why this happesn.

            Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote last edited by
            #5

            @johnzhou721 said in Why Does Minimization Immediately after Show and Activation Cause Non-Minimization?:

            Hi @SGaist! Sorry, latest PySide6, Linux, Fedora KDE Spin, X11.

            @JonB Ok... turns out still not minimizing after singleShot... somehow delaying by 100ms works...

            I'm interested in knowing why this happesn.

            because you are dealing with asyncronous events being handled by a window manager and the state information between app and X11 isn't consistent until you put in a delay to allow the interface to be "realized".

            For S&G tryi running your app as the sole X11 client (no window manager) to verify my suspicions.

            I light my way forward with the fires of all the bridges I've burned behind me.

            1 Reply Last reply
            1
            • J Offline
              J Offline
              johnzhou721
              wrote last edited by
              #6

              @Kent-Dorfman Alright, just learnt that X11 keeps its separate state. Is there a signal that signifies "finishes activating"? By the way this is purely theoretical as no reasonable userspace app would do that.

              Kent-DorfmanK 1 Reply Last reply
              0
              • J johnzhou721

                @Kent-Dorfman Alright, just learnt that X11 keeps its separate state. Is there a signal that signifies "finishes activating"? By the way this is purely theoretical as no reasonable userspace app would do that.

                Kent-DorfmanK Offline
                Kent-DorfmanK Offline
                Kent-Dorfman
                wrote last edited by
                #7

                @johnzhou721 said in Why Does Minimization Immediately after Show and Activation Cause Non-Minimization?:

                @Kent-Dorfman Alright, just learnt that X11 keeps its separate state. Is there a signal that signifies "finishes activating"?

                Not that I'm aware of, at least in any reliable way. There are introspection programs that can display information about a window, provided you know the windows handle id, but original X11 wasn't really designed with the feaure you seek in mind.

                However, certain desktop environment projects have invented complicated mousetraps to address some of these issues...ie dbus comms between apps. I won't mention the project itself by name because I'm an outspoken critic of it. LOL

                I light my way forward with the fires of all the bridges I've burned behind me.

                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