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. Restore a NOT VALID Dialog Position Correct
Forum Updated to NodeBB v4.3 + New Features

Restore a NOT VALID Dialog Position Correct

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 419 Views 2 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.
  • V Offline
    V Offline
    Volker75
    wrote on last edited by
    #1

    Hallo,

    I am not using the Qt Designer. I am coding the dialogs in Qt/c++ myself.

    So far I save and restore the size and position of dialogs and it working fine.
    I restore them just by lines like this:
    resize(TSettings->viewTeachersDialog_size);
    move(TSettings->viewTeachersDialog_pos);

    It is working fine as long as the display is not changed. But if someone saved the dialog on his second screen, close the application, unplug the second screen and restart the application, then the dialog is restored out of screen (of course). This sadly happen to laptop users that sometimes use a second screen at work.

    So i wonder how to avoid this best.

    By reading the screen resolution and check if the "move(pos)" is smaller then the resolution?
    But what should i read best? QScreen size or QScreen virtualSize or ...?
    Or is there something like a "valid" check if the dialog is on screen?

    And what is the best new value? At 0,0 might be the task bar. So better place it in the center?

    Any advice for me?

    Thank you

    SGaistS 1 Reply Last reply
    0
    • V Volker75

      Hallo,

      I am not using the Qt Designer. I am coding the dialogs in Qt/c++ myself.

      So far I save and restore the size and position of dialogs and it working fine.
      I restore them just by lines like this:
      resize(TSettings->viewTeachersDialog_size);
      move(TSettings->viewTeachersDialog_pos);

      It is working fine as long as the display is not changed. But if someone saved the dialog on his second screen, close the application, unplug the second screen and restart the application, then the dialog is restored out of screen (of course). This sadly happen to laptop users that sometimes use a second screen at work.

      So i wonder how to avoid this best.

      By reading the screen resolution and check if the "move(pos)" is smaller then the resolution?
      But what should i read best? QScreen size or QScreen virtualSize or ...?
      Or is there something like a "valid" check if the dialog is on screen?

      And what is the best new value? At 0,0 might be the task bar. So better place it in the center?

      Any advice for me?

      Thank you

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You could save the screen as well and if there's a mismatch on load, show the dialog on the default screen.

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

      V 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You could save the screen as well and if there's a mismatch on load, show the dialog on the default screen.

        V Offline
        V Offline
        Volker75
        wrote on last edited by
        #3

        @SGaist hmm.... If there is a mismatch, then just don't move at all and keep the default value by Qt?
        Yes, that sounds clever. I will try.
        Thank you

        M 1 Reply Last reply
        0
        • V Volker75

          @SGaist hmm.... If there is a mismatch, then just don't move at all and keep the default value by Qt?
          Yes, that sounds clever. I will try.
          Thank you

          M Offline
          M Offline
          mpergand
          wrote on last edited by
          #4

          @Volker75
          Have you tried with saveGeometry/restoreGeometry ?

          V 1 Reply Last reply
          0
          • M mpergand

            @Volker75
            Have you tried with saveGeometry/restoreGeometry ?

            V Offline
            V Offline
            Volker75
            wrote on last edited by
            #5

            @mpergand no. I saved it like this:
            TSettings->viewTeachersDialog_size=size();
            TSettings->viewTeachersDialog_pos=pos();

            saveGeometry and restoreGeometry haven't got that bug? I will try. Thank you for suggesting.

            V 1 Reply Last reply
            0
            • V Volker75

              @mpergand no. I saved it like this:
              TSettings->viewTeachersDialog_size=size();
              TSettings->viewTeachersDialog_pos=pos();

              saveGeometry and restoreGeometry haven't got that bug? I will try. Thank you for suggesting.

              V Offline
              V Offline
              Volker75
              wrote on last edited by
              #6

              @Volker75 Hallo,

              hmm.... I used saveGeometry/restoreGeometry and it worked first fine.
              I used a laptop with a second screen. Placed the Qt dialog on the second screen and closed it. Unplugged the second screen and started my software again. Qt noticed the problem and opens the window on the other screen. That is fine.

              But then i done the same with my tower PC, since it has two screens installed. First it worked find, but then, as i unplugged screen 1 (instead of screen 2), then it doesn't restore on the enabled screen.
              hmm... Not sure if it is worth to write an official bug report about this. But it might be maybe a problem also for users.

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

                The thing is that without more details between your two machines it's hard to consider what might be going on.

                It can be OS dependent, desktop environment dependent, Qt version dependent, etc.

                One thing you can do in your code is to check whether the widget ends up in an existing screen and adjust if not.

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

                V 1 Reply Last reply
                0
                • SGaistS SGaist

                  The thing is that without more details between your two machines it's hard to consider what might be going on.

                  It can be OS dependent, desktop environment dependent, Qt version dependent, etc.

                  One thing you can do in your code is to check whether the widget ends up in an existing screen and adjust if not.

                  V Offline
                  V Offline
                  Volker75
                  wrote on last edited by
                  #8

                  @SGaist
                  The bug was produced with Qt 6.5.3 and Windows 10 22H2.
                  hmm... I think i will keep this bug until a user complains about it. It is maybe overenginiering to care about that.
                  I think Qt should normaly care about that correct.

                  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