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. Mirroring MainWindow to a second QMainWindow
Forum Updated to NodeBB v4.3 + New Features

Mirroring MainWindow to a second QMainWindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
mouse eventgrabqmainwindow
10 Posts 3 Posters 3.6k 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.
  • L Offline
    L Offline
    L Koziarz
    wrote on last edited by L Koziarz
    #1

    I'd like to be able to scale the main application window down below a factor of 1.0. (In case you're curious, I'm trying to show a 480x800 portrait UI that runs on an embedded target on my development PC, but the PC only has a 768px high display).

    Since QT_SCALE_FACTOR doesn't support values less than 1.0, I'm trying to mirror my application's QMainWindow into a second QMainWIndow.

    So far it's working, but when I take mouse events in the secondary window, scale them to the size of the primary window, and then post them to the primary MainWindow's widget, I lose mouseRelease events.

    From installing event filters and watching mouse clicks travel across, it looks like my primary window is grabbing the mouse when the mousePress event is posted from the secondary.

    How can I keep the secondary window to hold the mouse so it sees the release and then passes the release event to the primary?

    Or is there another way to remote display QMainWindow?

    jsulmJ 1 Reply Last reply
    0
    • L L Koziarz

      I'd like to be able to scale the main application window down below a factor of 1.0. (In case you're curious, I'm trying to show a 480x800 portrait UI that runs on an embedded target on my development PC, but the PC only has a 768px high display).

      Since QT_SCALE_FACTOR doesn't support values less than 1.0, I'm trying to mirror my application's QMainWindow into a second QMainWIndow.

      So far it's working, but when I take mouse events in the secondary window, scale them to the size of the primary window, and then post them to the primary MainWindow's widget, I lose mouseRelease events.

      From installing event filters and watching mouse clicks travel across, it looks like my primary window is grabbing the mouse when the mousePress event is posted from the secondary.

      How can I keep the secondary window to hold the mouse so it sees the release and then passes the release event to the primary?

      Or is there another way to remote display QMainWindow?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @L-Koziarz Why do you want to scale your UI instead of resizing it?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      0
      • jsulmJ jsulm

        @L-Koziarz Why do you want to scale your UI instead of resizing it?

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

        @jsulm The target application is an embedded UI running on a 480x800 LCD in portrait mode. For customer demonstration and development purposes, I'd like the application to also work on Win32/64. In previous projects this hasn't been a big problem, but in this particular case we have some laptops that do not have an 800px high screen.

        Resizing and/or scrolling the MainWindow is certainly an option, but doesn't allow one to fully see the screen and/or manipulate objects in the corners.

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

          Hi
          Just as a note. on amd/nvdia , you can add custom resolutions.
          https://www.monitortests.com/forum/Thread-Custom-Resolution-Utility-CRU

          Unless the laptop cant actually display 800 in height. As in too high. :)

          1 Reply Last reply
          0
          • L Offline
            L Offline
            L Koziarz
            wrote on last edited by
            #5

            Hi mrjj,

            That's indeed a possible solution, and one I wish Microsoft was including in all versions of Windows. Apple has had this for what, nearly a decade now?

            Unfortunately this Windows build might go out as a sales/training tool into a field of machines with unknown hardware. Scaling the display on a plain box is my only hope of success.

            mrjjM 1 Reply Last reply
            0
            • L L Koziarz

              Hi mrjj,

              That's indeed a possible solution, and one I wish Microsoft was including in all versions of Windows. Apple has had this for what, nearly a decade now?

              Unfortunately this Windows build might go out as a sales/training tool into a field of machines with unknown hardware. Scaling the display on a plain box is my only hope of success.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @L-Koziarz
              Hi
              Well only the good old and dead Win XP cannot do it even if drivers
              support it. That said, not all , older intel onboard chips would use
              it. Even it should support it Windows wise.
              (win 7 was tested on older laptops)

              So I agree deployment on unknown hardware and using
              EDID override might end being a mess/nightmare.

              I was wondering if you tested with
              http://doc.qt.io/qt-5/qwidget.html#grabMouse
              Its docs says
              "Qt grabs the mouse when a mouse button is pressed and keeps it until the last button is released."
              Which does sounds like what you are seeing. ?

              1 Reply Last reply
              0
              • L Offline
                L Offline
                L Koziarz
                wrote on last edited by L Koziarz
                #7

                QWidget::grabMouse doesn't seem to work correctly when posting a mouseEvent to another QWidget after the call to grabMouse(). The side effects are really bad. This is 5.9 on Win64 desktop.

                mrjjM 1 Reply Last reply
                0
                • L L Koziarz

                  QWidget::grabMouse doesn't seem to work correctly when posting a mouseEvent to another QWidget after the call to grabMouse(). The side effects are really bad. This is 5.9 on Win64 desktop.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @L-Koziarz
                  Did you try to call releaseMouse() ?
                  And then forward event?
                  Just asking. Did not test if that is even worse :)

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    L Koziarz
                    wrote on last edited by
                    #9

                    The grab and release sequence falls apart when generating a new press into another widget.

                    I'm giving up on this approach and telling the client that Qt scaling will never be able to zoom out.

                    mrjjM 1 Reply Last reply
                    0
                    • L L Koziarz

                      The grab and release sequence falls apart when generating a new press into another widget.

                      I'm giving up on this approach and telling the client that Qt scaling will never be able to zoom out.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #10

                      @L-Koziarz
                      Yep its sounds somewhat convoluted
                      but never the less - exciting approach .
                      I wish it had worked as prof of concept but it seems there are issues.

                      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