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. QMessageBox not centered on application
Forum Updated to NodeBB v4.3 + New Features

QMessageBox not centered on application

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 5 Posters 844 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    Qt 6.8.0 on Linux (Ubuntu). Given:

    QString message{ tr("Do you want to save the modifications?", "IDS_MSG_SAVEMODIFICATIONS") };
    auto result = QMessageBox::question(this, "DeepSkyStacker",
    	message, (QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel), QMessageBox::No);
    

    I would expect the message box to be centered on the application or even the sub-window (this). However it appeared to be centered on the desktop.

    What could I be doing wrong?

    Thanks
    David

    JonBJ 1 Reply Last reply
    0
    • I Offline
      I Offline
      IgKh
      wrote on last edited by IgKh
      #11

      To try and help op progress, according to this the graphical system built into WSL uses the Weston compositor (not Gnome/Mutter), and it can't be (easily) replaced. I tried with a standalone Weston instance locally, and can reproduce the issue - the modal QMessageBox just pop ups at a random location each time, while under KWin it always opens centered in the parent window. So it would be a Weston issue.

      I couldn't find the exact issue in its' issue tracker, so if it something really blocking you I suppose you can open an issue - though more research is probably needed to make a useful bug report. Otherwise, install a Windows X server and do X11 forwarding to the host.

      1 Reply Last reply
      0
      • PerdrixP Perdrix

        Qt 6.8.0 on Linux (Ubuntu). Given:

        QString message{ tr("Do you want to save the modifications?", "IDS_MSG_SAVEMODIFICATIONS") };
        auto result = QMessageBox::question(this, "DeepSkyStacker",
        	message, (QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel), QMessageBox::No);
        

        I would expect the message box to be centered on the application or even the sub-window (this). However it appeared to be centered on the desktop.

        What could I be doing wrong?

        Thanks
        David

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by
        #2

        @Perdrix
        Are you running under Wayland by any chance? Default depends on your version of Ubuntu/desktop. Wayland compositor positions windows for you, and you can't tell it to do otherwise. Complain to Wayland people if you don't like it (lots of us don't). Plenty of posts to this effect of Wayland on this forum.

        Pl45m4P 1 Reply Last reply
        0
        • PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by
          #3

          Yes - it was running on WSL which uses Wayland - how to get their attention?

          D.

          JonBJ 1 Reply Last reply
          0
          • PerdrixP Perdrix

            Yes - it was running on WSL which uses Wayland - how to get their attention?

            D.

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by JonB
            #4

            @Perdrix said in QMessageBox not centered on application:

            how to get their attention?

            LOL :) I gave up on Wayland because (a) it's no longer possible to resize MySQL Workbench application at all and (b) it makes desktop more or less unusable in VirtualBox due to serious screen tearing and mouse cursor overlay, the folks know about it but just say Wayland is not supported. So I have had to go back to Xorg, and thankfully don't worry about Wayland issues now.

            1 Reply Last reply
            0
            • JonBJ JonB

              @Perdrix
              Are you running under Wayland by any chance? Default depends on your version of Ubuntu/desktop. Wayland compositor positions windows for you, and you can't tell it to do otherwise. Complain to Wayland people if you don't like it (lots of us don't). Plenty of posts to this effect of Wayland on this forum.

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #5

              @JonB said in QMessageBox not centered on application:

              Complain to Wayland people if you don't like it (lots of us don't)

              But why is it like that?! I don't get it...
              I don't know anyone who is like "Oh yeah, Wayland is great(er than all the Window Managers before)".
              Maybe under the hood since it's more modern/newer but no being able to position windows?! Cmon...


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              JonBJ 1 Reply Last reply
              0
              • Pl45m4P Pl45m4

                @JonB said in QMessageBox not centered on application:

                Complain to Wayland people if you don't like it (lots of us don't)

                But why is it like that?! I don't get it...
                I don't know anyone who is like "Oh yeah, Wayland is great(er than all the Window Managers before)".
                Maybe under the hood since it's more modern/newer but no being able to position windows?! Cmon...

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by JonB
                #6

                @Pl45m4
                For my part I haven't seen anything to like in it. I think it may (well) be lighter weight than Xorg. That may be a big factor. There must be a good reason why Ubuntu/GNOME has gone default Wayland. It's not that you "can't" position your window, it's that its philosophy is that you're "not allowed" to do that, it chooses where to put desktop things.

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  IgKh
                  wrote on last edited by
                  #7

                  A not uninteresting distinction to make here is that Wayland does allow applications to position their surfaces relative to each other, but not globally. So a modal dialog being shown centered on its' parent window is something that the protocol allows (well, technically the xdg-shell extension protocol). Qt implements that, at least KDE respects that (just double checked that the expected behavior happens on KDE Wayland), Gnome appears to not respect that.

                  I think Wayland has some good design decisions, but also some very bad ones, and the worst one IMO is that the roles of display server and window manager were combined into a single program (the compositor) so if you don't like a compositor's window management style but its' display server side is the one most integrated into the environment (i.e supports the needed graphics card or whatever) - though luck!

                  @Perdrix I don't know if it is possible in WSL, but I'd try to change the desktop environment from Gnome to KDE or something else (maybe DWL). Gnome is far too hostile to anything which does not fully subsribe to its' world view - which includes Gtk3/4 and libadwaita. Qt tries its' best, but it is often not enough.

                  1 Reply Last reply
                  1
                  • S Offline
                    S Offline
                    SamiV123
                    wrote on last edited by
                    #8

                    This is offtopic but as a native Linux user the last time (about a year ago) I looked at migrating from X11 to Wayland everything was alpha quality with a ton of bugs cropping up everywhere. To be fair most things were advertised as such (missing features, plenty of bugs and sharp edges).

                    The old wisdom goes that "once you're 90% done you just need to take care of the other 90%" applies here.

                    To go from a hobbyist weekend project (which it is at the moment) to a product that just works is a relentless boring grind where one has no choice but to work through the bugs and missing features and fix the sharp edges.

                    The common problem in open source is that nobody wants to do this boring and inglorious grunt work so it's not done.

                    I estimate that it'll take another 20-30 years of slow maturing until Wayland is "ready".

                    1 Reply Last reply
                    0
                    • PerdrixP Offline
                      PerdrixP Offline
                      Perdrix
                      wrote on last edited by
                      #9

                      Sad to say I am inclined to agree with you. I hate this "flavour du jour" thing that seems to happen a lot with Linux distros.

                      1 Reply Last reply
                      0
                      • JonBJ Online
                        JonBJ Online
                        JonB
                        wrote on last edited by JonB
                        #10

                        As I wrote earlier, I have just reverted my Ubuntu 24.04 GNOME from its default Wayland to Xorg because of problems. I don't fully understand why Ubuntu considers Wayland ready to be the default since 22.04.

                        1 Reply Last reply
                        0
                        • I Offline
                          I Offline
                          IgKh
                          wrote on last edited by IgKh
                          #11

                          To try and help op progress, according to this the graphical system built into WSL uses the Weston compositor (not Gnome/Mutter), and it can't be (easily) replaced. I tried with a standalone Weston instance locally, and can reproduce the issue - the modal QMessageBox just pop ups at a random location each time, while under KWin it always opens centered in the parent window. So it would be a Weston issue.

                          I couldn't find the exact issue in its' issue tracker, so if it something really blocking you I suppose you can open an issue - though more research is probably needed to make a useful bug report. Otherwise, install a Windows X server and do X11 forwarding to the host.

                          1 Reply Last reply
                          0
                          • PerdrixP Perdrix has marked this topic as solved on
                          • PerdrixP Offline
                            PerdrixP Offline
                            Perdrix
                            wrote on last edited by
                            #12

                            For various reasons I've trashed WSL, so this is no longer an issue :) I've installed an Lubuntu 22.04 build VM

                            JonBJ 1 Reply Last reply
                            0
                            • PerdrixP Perdrix

                              For various reasons I've trashed WSL, so this is no longer an issue :) I've installed an Lubuntu 22.04 build VM

                              JonBJ Online
                              JonBJ Online
                              JonB
                              wrote on last edited by
                              #13

                              @Perdrix
                              Is your VM manager VirtualBox? I and others have had lots of trouble with Wayland. Ubuntu, don't know if it would be same for Lubuntu.

                              1 Reply Last reply
                              0
                              • PerdrixP Offline
                                PerdrixP Offline
                                Perdrix
                                wrote on last edited by Perdrix
                                #14

                                WSL was Hyper-V. Lubuntu install is in VMware Workstation

                                JonBJ 1 Reply Last reply
                                0
                                • PerdrixP Perdrix

                                  WSL was Hyper-V. Lubuntu install is in VMware Workstation

                                  JonBJ Online
                                  JonBJ Online
                                  JonB
                                  wrote on last edited by
                                  #15

                                  @Perdrix
                                  Then you may fare better with Wayland than I did, if you have to use it!

                                  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