Focus rectangles macOS
-
Hi, this is quite a common problem I guess, but I can't seem to find any "standard" solution to this. I'm developing a cross-platform library (macOS/Windows) which dynamically loads UI files using a subclassed QUiLoader.
1st part of the question: I created some sample .ui files on Windows, and when the files are loaded and application is shown, everything is just like I designed it. But on macOS, there needs to be an extra space for some controls (especially those, which are focusable) for them to be able to show a focus rectangle properly.
E.g. for QPushButton (111x23px):
-
Windows - OK button is nicely shown, focus rectangle as well

-
macOS - button and focus rectangle are not fully shown - not enough space

If I make the button 31px high, it's okay on macOS but it's too big on Windows. The same applies to QComboBox and other controls. I know, that this can be solved by using different .ui files for different control but I would like to do it using 1 .ui file. Do I have to dynamically change the button's height in the code if I'm on the Windows platform or is there a better solution?
2nd part of the question - also regarding focus rectangle on macOS. QCheckBox seems to have a problem showing its focus rectangle and it doesn't matter how big it is. It only shows some weird dot in the top-left corner:

Native macOS checkboxes show the focus rectangle like this:

I'm using Qt 5.12.9, Windows 10, and macOS 10.15.6 (but both problems were valid also on Qt 5.14.1 and older macOS versions). Thanks in advance.
-
-
Don't hardcode sizes. Even if it looks correct on some platform there's no guarantee there won't be an OS update that changes some sizes or effects and your ui will break. Hardcoding sizes can also lead to broken ui on monitors with different scaling factor than yours. Use layouts to manage widget placement and sizes. They take care of platform differences for you.
-
Don't hardcode sizes. Even if it looks correct on some platform there's no guarantee there won't be an OS update that changes some sizes or effects and your ui will break. Hardcoding sizes can also lead to broken ui on monitors with different scaling factor than yours. Use layouts to manage widget placement and sizes. They take care of platform differences for you.
@Chris-Kawa This is a problem since I'm working on the library that wraps also frameworks other than Qt and some of them don't support dynamic layouts - and I don't really have time to implement that support myself. Hard-coded positions and sizes are enough for now. I guess I will have to do it using macros from withing the code and change the size there. I just have to find a reasonable way, because buttons with a larger height could be desired in some places - in others, they should be of standard height - cca 21px in Windows. And how about the checkbox focus rectangle issue, has anybody encountered this?