Setting border on widget is inconsistent
-
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:

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. -
This post is deleted!
-
Hi and welcome to devnet,
Which version of Qt are you using ?
On which OS ? -
@SGaist I am using Qt version 6.10.2 on windows 10, and thank you.
-
@SGaist I am using Qt version 6.10.2 on windows 10, and thank you.
@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.
-
@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.
@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-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.
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. -
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.@Chris-Kawa Thank you so much for all the help!