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. QT6 on Ubuntu 22.04 strange widget behavior

QT6 on Ubuntu 22.04 strange widget behavior

Scheduled Pinned Locked Moved Unsolved General and Desktop
34 Posts 4 Posters 5.1k 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.
  • J Offline
    J Offline
    Josef Lintz
    wrote on last edited by
    #3

    I don't know if "self-bumping" is against the rules, but I really need help with this

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Josef Lintz
      wrote on last edited by
      #4

      I have an update, no solution yet, but an update.

      A user on Reddit suggested to that I run the app with -style fusion and -platform xcb, there wasn't much change there. Then he suggested I use export QT_LOGGING_RULES=*.debug=true before running the app, I ran the app once with XDG_CURRENT_DESKTOP set, and once with unset XDG_CURRENT_DESKTOP.

      Comparing the two files, I found the following
      .qpa.theme: Attempting to create platform theme "gtk3" via QPlatformThemeFactory::createqt.core.library: "/home/vbboard1/Qt/6.5.1/gcc_64/plugins/platformthemes/libqgtk3.so" loaded libraryqt.qpa.theme.dbus: "" "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" "SettingChanged"qt.qpa.gtk: Color map populated from defaults.qt.qpa.gtk: GTK theme initialized: "Yaru" Qt::ColorScheme::Lightqt.qpa.theme: Successfully created platform theme "gtk3"

      As I understand, "Yaru" is a type of theme used by KDE. Why is it being loaded here with Ubuntu on gnome. Is there any way I can disable it?

      JoeCFDJ 2 Replies Last reply
      0
      • J Josef Lintz

        I have an update, no solution yet, but an update.

        A user on Reddit suggested to that I run the app with -style fusion and -platform xcb, there wasn't much change there. Then he suggested I use export QT_LOGGING_RULES=*.debug=true before running the app, I ran the app once with XDG_CURRENT_DESKTOP set, and once with unset XDG_CURRENT_DESKTOP.

        Comparing the two files, I found the following
        .qpa.theme: Attempting to create platform theme "gtk3" via QPlatformThemeFactory::createqt.core.library: "/home/vbboard1/Qt/6.5.1/gcc_64/plugins/platformthemes/libqgtk3.so" loaded libraryqt.qpa.theme.dbus: "" "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" "SettingChanged"qt.qpa.gtk: Color map populated from defaults.qt.qpa.gtk: GTK theme initialized: "Yaru" Qt::ColorScheme::Lightqt.qpa.theme: Successfully created platform theme "gtk3"

        As I understand, "Yaru" is a type of theme used by KDE. Why is it being loaded here with Ubuntu on gnome. Is there any way I can disable it?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #5

        @Josef-Lintz If you want to set them for your app only, you can do it in main()
        with
        qunsetenv("GNOME_DESKTOP_SESSION_ID");
        qunsetenv( "XDG_CURRENT_DESKTOP" );
        before QApplication app call. These settings will affect your app only.

        J 1 Reply Last reply
        0
        • J Josef Lintz

          I have an update, no solution yet, but an update.

          A user on Reddit suggested to that I run the app with -style fusion and -platform xcb, there wasn't much change there. Then he suggested I use export QT_LOGGING_RULES=*.debug=true before running the app, I ran the app once with XDG_CURRENT_DESKTOP set, and once with unset XDG_CURRENT_DESKTOP.

          Comparing the two files, I found the following
          .qpa.theme: Attempting to create platform theme "gtk3" via QPlatformThemeFactory::createqt.core.library: "/home/vbboard1/Qt/6.5.1/gcc_64/plugins/platformthemes/libqgtk3.so" loaded libraryqt.qpa.theme.dbus: "" "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" "SettingChanged"qt.qpa.gtk: Color map populated from defaults.qt.qpa.gtk: GTK theme initialized: "Yaru" Qt::ColorScheme::Lightqt.qpa.theme: Successfully created platform theme "gtk3"

          As I understand, "Yaru" is a type of theme used by KDE. Why is it being loaded here with Ubuntu on gnome. Is there any way I can disable it?

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #6

          @Josef-Lintz https://wiki.archlinux.org/title/Xdg-utils

          XDG_CURRENT_DESKTOP=ubuntu:GNOME because you installed gnome.
          mine is LXQt. You may need to make your code working for different settings.

          J 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @Josef-Lintz If you want to set them for your app only, you can do it in main()
            with
            qunsetenv("GNOME_DESKTOP_SESSION_ID");
            qunsetenv( "XDG_CURRENT_DESKTOP" );
            before QApplication app call. These settings will affect your app only.

            J Offline
            J Offline
            Josef Lintz
            wrote on last edited by Josef Lintz
            #7

            @JoeCFD Thanks for the suggestion. I actually came up with a similar way to run the programs. I simply prefixed the program name with . and created a bash file with the same name as the program and before launching the program I do:
            unset GNOME_DESKTOP_SESSION_ID
            unset XDG_CURRENT_DESKTOP

            But this doesn't solve the underlying issue. Why is it that on my system (A fresh install, bare in mind) with QT installed using the online installer, I get 3 different conflicting "styles(?)", when in designer, when running, or when modifying window/focus.

            Also, your approach and mine still has the same issue(s), I have to do this for a lot of programs we use, so it's not very feasible.
            And, it's only recently I noticed this issue, when I do
            unset GNOME_DESKTOP_SESSION_ID
            unset XDG_CURRENT_DESKTOP
            Some of the widgets still appear wrong, I asked a question about this a while back (This was for Ubuntu 16.04). It ended up being an environment variable not being set correctly.

            So, even if doing
            unset GNOME_DESKTOP_SESSION_ID
            unset XDG_CURRENT_DESKTOP
            seems to work, it doesn't fix the issue fully

            1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              @Josef-Lintz https://wiki.archlinux.org/title/Xdg-utils

              XDG_CURRENT_DESKTOP=ubuntu:GNOME because you installed gnome.
              mine is LXQt. You may need to make your code working for different settings.

              J Offline
              J Offline
              Josef Lintz
              wrote on last edited by
              #8

              @JoeCFD Longshot. But do you know any QT "dependent" XDG settings which could affect this issue?

              JoeCFDJ 1 Reply Last reply
              0
              • J Josef Lintz

                @JoeCFD Longshot. But do you know any QT "dependent" XDG settings which could affect this issue?

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #9

                @Josef-Lintz Can you check this output?
                echo $XDG_SESSION_TYPE

                I do not think Qt should have any issue with the following setting.
                XDG_CURRENT_DESKTOP=ubuntu:GNOME

                J 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @Josef-Lintz Can you check this output?
                  echo $XDG_SESSION_TYPE

                  I do not think Qt should have any issue with the following setting.
                  XDG_CURRENT_DESKTOP=ubuntu:GNOME

                  J Offline
                  J Offline
                  Josef Lintz
                  wrote on last edited by Josef Lintz
                  #10

                  @JoeCFD

                  @Josef-Lintz Can you check this output?
                  echo $XDG_SESSION_TYPE

                  echo $XDG_SESSION_TYPE returns "x11"

                  I do not think Qt should have any issue with the following setting.
                  XDG_CURRENT_DESKTOP=ubuntu:GNOME

                  I think I figured out something. If I set XDG_CURRENT_DESKTOP to anyhing, not just unset it, I get the same result as the 3rd image. So, it's possible that XDG_CURRENT_DESKTOP is set correctly, but the preview/designer is wrong?
                  Also, still doesn't explain why the style changes when I move/resize the window

                  Axel SpoerlA 1 Reply Last reply
                  0
                  • J Josef Lintz

                    @JoeCFD

                    @Josef-Lintz Can you check this output?
                    echo $XDG_SESSION_TYPE

                    echo $XDG_SESSION_TYPE returns "x11"

                    I do not think Qt should have any issue with the following setting.
                    XDG_CURRENT_DESKTOP=ubuntu:GNOME

                    I think I figured out something. If I set XDG_CURRENT_DESKTOP to anyhing, not just unset it, I get the same result as the 3rd image. So, it's possible that XDG_CURRENT_DESKTOP is set correctly, but the preview/designer is wrong?
                    Also, still doesn't explain why the style changes when I move/resize the window

                    Axel SpoerlA Offline
                    Axel SpoerlA Offline
                    Axel Spoerl
                    Moderators
                    wrote on last edited by Axel Spoerl
                    #11

                    Hi @Josef-Lintz,
                    with Qt 6.5, a new version of Qt's GTK3 theme has been shipped, which generally improves GTK look and feel. I wrote it, so now you know whom to blame ;-)

                    Looking at your observations:

                    • When the widget containing the progress bar and the push button is moved or resized, it implicitly gets focus. I guess that's the reason why the colors change. They change from the Inactive to the Normal color group. That said, the new GTK3 styling probably makes a change visible, that had been invisible before.
                      You can check that by obtaining the widgets' palette e.g. with const QPalette &palette = ui->pushButton->palette();and inspecting their colors.
                      This, as an example returns the normal button color.
                      qDebug() << palette.color(QPalette::Normal, QPalette::Button).name();
                      (change Normalto Inactive to retrieve the initial colors)

                    • Furthermore, this patch landed in 6.5.2 yesterday. It is (under more) related to the Yaru style. In essence, the GTK button foreground was used for the WindowText, before it would fall back to other (more suitable) colors. That has worked nicely for some GTK themes, but was unfortunate for others. It affects only text color, but since you are working with Yaru, I found it worth mentioning.

                    Cheers
                    Axel

                    PS: Thanks to @Matthias-Rauter for prompting.

                    Software Engineer
                    The Qt Company, Oslo

                    J 1 Reply Last reply
                    1
                    • Axel SpoerlA Axel Spoerl

                      Hi @Josef-Lintz,
                      with Qt 6.5, a new version of Qt's GTK3 theme has been shipped, which generally improves GTK look and feel. I wrote it, so now you know whom to blame ;-)

                      Looking at your observations:

                      • When the widget containing the progress bar and the push button is moved or resized, it implicitly gets focus. I guess that's the reason why the colors change. They change from the Inactive to the Normal color group. That said, the new GTK3 styling probably makes a change visible, that had been invisible before.
                        You can check that by obtaining the widgets' palette e.g. with const QPalette &palette = ui->pushButton->palette();and inspecting their colors.
                        This, as an example returns the normal button color.
                        qDebug() << palette.color(QPalette::Normal, QPalette::Button).name();
                        (change Normalto Inactive to retrieve the initial colors)

                      • Furthermore, this patch landed in 6.5.2 yesterday. It is (under more) related to the Yaru style. In essence, the GTK button foreground was used for the WindowText, before it would fall back to other (more suitable) colors. That has worked nicely for some GTK themes, but was unfortunate for others. It affects only text color, but since you are working with Yaru, I found it worth mentioning.

                      Cheers
                      Axel

                      PS: Thanks to @Matthias-Rauter for prompting.

                      J Offline
                      J Offline
                      Josef Lintz
                      wrote on last edited by Josef Lintz
                      #12

                      @Axel-Spoerl Thank you very much for the explanation.
                      So, it seems like a small bug(?) in how the styles are set-up. Ok, but it still begs the question as to why "normal" is different in the designer vs runtime? And is it something I can fix "locally" or do I need to wait for an update?

                      And one more thing, (kind of a silly question) I can't seem to update to QT 6.5.2, I tried the unified installer, and I only got listings up QT 6.5.1?
                      According to this, QT6.5.2 has not yet been "Realized", my bad

                      Axel SpoerlA 1 Reply Last reply
                      0
                      • J Josef Lintz

                        @Axel-Spoerl Thank you very much for the explanation.
                        So, it seems like a small bug(?) in how the styles are set-up. Ok, but it still begs the question as to why "normal" is different in the designer vs runtime? And is it something I can fix "locally" or do I need to wait for an update?

                        And one more thing, (kind of a silly question) I can't seem to update to QT 6.5.2, I tried the unified installer, and I only got listings up QT 6.5.1?
                        According to this, QT6.5.2 has not yet been "Realized", my bad

                        Axel SpoerlA Offline
                        Axel SpoerlA Offline
                        Axel Spoerl
                        Moderators
                        wrote on last edited by
                        #13

                        @Josef-Lintz
                        Hi Josef,
                        I understand the add-on-question. The widget designer provides an abstraction level to design widget based applications. It can't anticipate, where the application actually runs. Could be Linux/KDE, Linux/Gnome, Windows, macOS, dark mode, light mode. It doesn't have the ambition to completely emulate the look and feel of the local machine.
                        Cheers
                        Axel

                        Software Engineer
                        The Qt Company, Oslo

                        J 1 Reply Last reply
                        1
                        • Axel SpoerlA Axel Spoerl

                          @Josef-Lintz
                          Hi Josef,
                          I understand the add-on-question. The widget designer provides an abstraction level to design widget based applications. It can't anticipate, where the application actually runs. Could be Linux/KDE, Linux/Gnome, Windows, macOS, dark mode, light mode. It doesn't have the ambition to completely emulate the look and feel of the local machine.
                          Cheers
                          Axel

                          J Offline
                          J Offline
                          Josef Lintz
                          wrote on last edited by
                          #14

                          @Axel-Spoerl I truly appreciate that you're explaining what the issue is. But how can I fix it, is it even something "fixable" on my end, or do I need to wait for the next QT version?

                          JonBJ 1 Reply Last reply
                          0
                          • J Josef Lintz

                            @Axel-Spoerl I truly appreciate that you're explaining what the issue is. But how can I fix it, is it even something "fixable" on my end, or do I need to wait for the next QT version?

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

                            @Josef-Lintz
                            What are you expecting to be "fixed"? @Axel-Spoerl explained that Designer preview will not be identical to runtime. If it's that things look a bit different that is not going to change.

                            J 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @Josef-Lintz
                              What are you expecting to be "fixed"? @Axel-Spoerl explained that Designer preview will not be identical to runtime. If it's that things look a bit different that is not going to change.

                              J Offline
                              J Offline
                              Josef Lintz
                              wrote on last edited by Josef Lintz
                              #16

                              @JonB Well, if the designer is meant to preview how the program should look like, and it looks completely different from the preview during runtime, then I think the designer isn't working correctly (Assuming you don't do anything weird to the layout during runtime). And there should at least be a way to configure the designer, to make it preview the actual design more correctly.

                              (Bit of nit-pick I don't think calling it "slightly different" is doing this justice. Most of the widgets look completely different as to how they look in "design-time")

                              If the styling is different between design-time and runtime, maybe I can live with it. But the fact that the styles completely change when the widgets lose focus, is somewhat problematic, I guess that's the main issue here

                              I apologize if my earlier remarks came off as rude, that wasn't my intention.

                              J JonBJ Axel SpoerlA 3 Replies Last reply
                              0
                              • J Josef Lintz

                                @JonB Well, if the designer is meant to preview how the program should look like, and it looks completely different from the preview during runtime, then I think the designer isn't working correctly (Assuming you don't do anything weird to the layout during runtime). And there should at least be a way to configure the designer, to make it preview the actual design more correctly.

                                (Bit of nit-pick I don't think calling it "slightly different" is doing this justice. Most of the widgets look completely different as to how they look in "design-time")

                                If the styling is different between design-time and runtime, maybe I can live with it. But the fact that the styles completely change when the widgets lose focus, is somewhat problematic, I guess that's the main issue here

                                I apologize if my earlier remarks came off as rude, that wasn't my intention.

                                J Offline
                                J Offline
                                Josef Lintz
                                wrote on last edited by
                                #17
                                This post is deleted!
                                1 Reply Last reply
                                0
                                • J Josef Lintz

                                  @JonB Well, if the designer is meant to preview how the program should look like, and it looks completely different from the preview during runtime, then I think the designer isn't working correctly (Assuming you don't do anything weird to the layout during runtime). And there should at least be a way to configure the designer, to make it preview the actual design more correctly.

                                  (Bit of nit-pick I don't think calling it "slightly different" is doing this justice. Most of the widgets look completely different as to how they look in "design-time")

                                  If the styling is different between design-time and runtime, maybe I can live with it. But the fact that the styles completely change when the widgets lose focus, is somewhat problematic, I guess that's the main issue here

                                  I apologize if my earlier remarks came off as rude, that wasn't my intention.

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by
                                  #18

                                  @Josef-Lintz
                                  I only meant if it looks "somewhat" different. If it's, say, a completely wrong color that would indeed be bad. @Axel-Spoerl knows much more than I do about the specifics.

                                  1 Reply Last reply
                                  0
                                  • J Josef Lintz

                                    @JonB Well, if the designer is meant to preview how the program should look like, and it looks completely different from the preview during runtime, then I think the designer isn't working correctly (Assuming you don't do anything weird to the layout during runtime). And there should at least be a way to configure the designer, to make it preview the actual design more correctly.

                                    (Bit of nit-pick I don't think calling it "slightly different" is doing this justice. Most of the widgets look completely different as to how they look in "design-time")

                                    If the styling is different between design-time and runtime, maybe I can live with it. But the fact that the styles completely change when the widgets lose focus, is somewhat problematic, I guess that's the main issue here

                                    I apologize if my earlier remarks came off as rude, that wasn't my intention.

                                    Axel SpoerlA Offline
                                    Axel SpoerlA Offline
                                    Axel Spoerl
                                    Moderators
                                    wrote on last edited by
                                    #19

                                    @Josef-Lintz said in QT6 on Ubuntu 22.04 strange widget behavior:

                                    if the designer is meant to preview how the program should look like

                                    I can understand the point. However, it would make the widget designer way more complex. Where should the line be drawn? Should it emulate macOS look'n'feel on Linux? Gnome YaruDark on Windows in light mode?

                                    But that's getting us off topic: If there's anything we can improve on the GTK theming shipped with Qt 6.5, I'd be grateful for any input. And, as @JonB said, if the widget designer shows something completely odd, just point it out.

                                    Software Engineer
                                    The Qt Company, Oslo

                                    J 1 Reply Last reply
                                    1
                                    • Axel SpoerlA Axel Spoerl

                                      @Josef-Lintz said in QT6 on Ubuntu 22.04 strange widget behavior:

                                      if the designer is meant to preview how the program should look like

                                      I can understand the point. However, it would make the widget designer way more complex. Where should the line be drawn? Should it emulate macOS look'n'feel on Linux? Gnome YaruDark on Windows in light mode?

                                      But that's getting us off topic: If there's anything we can improve on the GTK theming shipped with Qt 6.5, I'd be grateful for any input. And, as @JonB said, if the widget designer shows something completely odd, just point it out.

                                      J Offline
                                      J Offline
                                      Josef Lintz
                                      wrote on last edited by Josef Lintz
                                      #20

                                      @Axel-Spoerl

                                      I can understand the point. However, it would make the widget designer way more complex. Where should the line be drawn? Should it emulate macOS look'n'feel on Linux? Gnome YaruDark on Windows in light mode?

                                      I mean, why not though? Isn't the point of the designer to preview how your program is going to look like? Having a designer which produces different output while in "design-mode" vs runtime, kinda defeats the point of having a designer?
                                      QT apps (as far as I saw) already support theming, even "cross-platrform" themes, I can have a "Windows-looking" QT app run on Ubuntu. So I don't see the problem with said "line". I guess by default the designer should look like the system-theme, unless specified otherwise by the user.
                                      If it's an issue of complexity, since QT Widgets is less supported than QT Quick, I can understand.

                                      But that's getting us off topic: If there's anything we can improve on the GTK theming shipped with Qt 6.5, I'd be grateful for any input. And, as @JonB said, if the widget designer shows something completely odd, just point it out.

                                      This is interesting, am I the first person to encounter this "issue"? Has nobody on Ubuntu 22.04 encountered this problem before? When installing Ubuntu I chose the "Minimal installation" option, could it be that it skipped something that a "Full installation" uses?

                                      1 Reply Last reply
                                      0
                                      • J Offline
                                        J Offline
                                        Josef Lintz
                                        wrote on last edited by
                                        #21

                                        And one more thing, I just want to make sure that everyone understands by what I mean when I say "It looks different"

                                        This is design-time
                                        DesignTime.png

                                        This is runtime
                                        Runtime.png

                                        This is runtime-unfocused
                                        Runtime-unfocusedpng.png

                                        JonBJ 1 Reply Last reply
                                        0
                                        • J Josef Lintz

                                          And one more thing, I just want to make sure that everyone understands by what I mean when I say "It looks different"

                                          This is design-time
                                          DesignTime.png

                                          This is runtime
                                          Runtime.png

                                          This is runtime-unfocused
                                          Runtime-unfocusedpng.png

                                          JonBJ Offline
                                          JonBJ Offline
                                          JonB
                                          wrote on last edited by
                                          #22

                                          @Josef-Lintz
                                          Just so we are clear:

                                          • Are you saying there is something wrong/unacceptable between the design time and the runtime other than the change of color?
                                          • If the only issue is the change to orange color at runtime when (the window is?) unfocussed, then I would agree that would be surprising. Unless something about the desktop manage or the theme intends a dramatic change of color when not focussed.

                                          Caveat that I don't use Qt6 and don't know anything about @Axel-Spoerl's "GTK theming shipped with Qt 6.5", so if that's what it's about I'm out of my depth.

                                          Axel SpoerlA 1 Reply Last reply
                                          1

                                          • Login

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