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. Setting border on widget is inconsistent
Qt 6.11 is out! See what's new in the release blog

Setting border on widget is inconsistent

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 491 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.
  • R Offline
    R Offline
    rida_zouga
    wrote last edited by
    #1

    in QtDesigner, when setting for example the following StyleSheet on a QLabel using the Property Editor

    QLabel {
     font-size: 26px;
     color: blue;
     border: 1px solid black;
    }
    

    this is the result:
    97eacf3d-7668-4b82-b620-22e4777e95ac-image.png
    Notice how the left and top borders are relatively thinner than the bottom and right one, couldn't find any solution or similar post talking about this slight issue, and Thanks for your suggestions.

    1 Reply Last reply
    0
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote last edited by SGaist
        #3

        Hi and welcome to devnet,

        Which version of Qt are you using ?
        On which OS ?

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

        R 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Which version of Qt are you using ?
          On which OS ?

          R Offline
          R Offline
          rida_zouga
          wrote last edited by
          #4

          @SGaist I am using Qt version 6.10.2 on windows 10, and thank you.

          Chris KawaC 1 Reply Last reply
          0
          • R rida_zouga

            @SGaist I am using Qt version 6.10.2 on windows 10, and thank you.

            Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote last edited by
            #5

            @rida_zouga What's your scaling setting in the system's monitor options? This can happen with non-integer multipliers, e.g 125% or 150%. At those scaling values 1px lines become slightly larger (e.g. 1.25px), and depending on where they fall on the grid they can end up being averaged across 2 pixels.

            R 1 Reply Last reply
            2
            • Chris KawaC Chris Kawa

              @rida_zouga What's your scaling setting in the system's monitor options? This can happen with non-integer multipliers, e.g 125% or 150%. At those scaling values 1px lines become slightly larger (e.g. 1.25px), and depending on where they fall on the grid they can end up being averaged across 2 pixels.

              R Offline
              R Offline
              rida_zouga
              wrote last edited by
              #6

              @Chris-Kawa Wow Thank you so much, my resolution was indeed 150% and that's why the border was not consistent (along other quirks too), but as soon as I changed to 100% the border works perfectly well, though I guess now is there a fix for the resolutions causing a problem? and Thank you once again.

              Chris KawaC 1 Reply Last reply
              0
              • R rida_zouga

                @Chris-Kawa Wow Thank you so much, my resolution was indeed 150% and that's why the border was not consistent (along other quirks too), but as soon as I changed to 100% the border works perfectly well, though I guess now is there a fix for the resolutions causing a problem? and Thank you once again.

                Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote last edited by
                #7

                @rida_zouga:

                is there a fix for the resolutions causing a problem?

                Well, it's not exactly a bug, so there's nothing to fix really. If you have a line width of 1px and you scale it to 1.5px you can't really color half a pixel (well, you could if you go into the RGB subpixels like font antialiasing does, but that's beyond the point), so you either round up, down or average brightness across all covered pixels. None of those is perfect in all scenarios, for example rounding down lines at oblique angles can lead to holes in the line and averaging can lead to widening or blurriness.

                The only thing you can do to avoid it is not use non-integer scale factors. Qt lets you choose if you want to use the system setting, ignore it completely or round up or down. Rounding down should let you keep the 1px borders intact, but keep in mind that it can lead to text and other elements look too small on some displays.
                See QGuiApplication::setHighDpiScaleFactorRoundingPolicy for more details, but use with care and test on multiple different displays if possible.

                R 1 Reply Last reply
                2
                • Chris KawaC Chris Kawa

                  @rida_zouga:

                  is there a fix for the resolutions causing a problem?

                  Well, it's not exactly a bug, so there's nothing to fix really. If you have a line width of 1px and you scale it to 1.5px you can't really color half a pixel (well, you could if you go into the RGB subpixels like font antialiasing does, but that's beyond the point), so you either round up, down or average brightness across all covered pixels. None of those is perfect in all scenarios, for example rounding down lines at oblique angles can lead to holes in the line and averaging can lead to widening or blurriness.

                  The only thing you can do to avoid it is not use non-integer scale factors. Qt lets you choose if you want to use the system setting, ignore it completely or round up or down. Rounding down should let you keep the 1px borders intact, but keep in mind that it can lead to text and other elements look too small on some displays.
                  See QGuiApplication::setHighDpiScaleFactorRoundingPolicy for more details, but use with care and test on multiple different displays if possible.

                  R Offline
                  R Offline
                  rida_zouga
                  wrote last edited by
                  #8

                  @Chris-Kawa Thank you so much for all the help!

                  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