[Interest] how to get 3 pixel focus ring?
John Weeks
john at wavemetrics.com
Mon Jun 8 22:40:06 CEST 2020
One thing to be aware of when using QMacStyle or QWindowsStyle is that they are trying to emulate the Macintosh or Windows mandated look. The blue focus ring is a Macintosh thing, and like many things Apple, it comes in one size. The width of the blue line is mandated.
On Windows, when I ran your test, it looks like you are getting the standard Windows dotted-line focus ring. Usually it's a bit inset from the edges of the edit box, though. Once again, QWindowsStyle is giving you the Windows look, and that's it.
You might try Fusion style, we have found that the look isn't bad, but it doesn't look like either Windows or Macintosh.
Hope this helps....
-John Weeks
> On Jun 8, 2020, at 12:48 PM, David M. Cotter <dave at kjams.com> wrote:
>
> can anyone explain why tree view looks fine but table view only has 1 pixel?
>
> @adam did you download the example project? it's trivial to run and you can test several implementations. which impl would be used with your suggestion of PM_FocusFrame margins?
> and do you have maybe example code to implement your suggestion?
>
> part of my question is: is this a bug in Qt ? because IMHO "QFocusFrame" should "just work", and why does it NOT?
>
> or setting the style to 3 px should "just work" and why does it NOT work but only for certain widgets?
>
> you'd think that QFocusFrame would *manage* the clipping properly?
>
> or the doc should be more clear, with sample code, cuz i've read the doc several times and am no further along :(
>
> any help would be greatly appreciated! if you like karaoke, i have an app for you ;-)
>
> -dave
>
>> On Jun 8, 2020, at 5:18 AM, Adam Light <aclight at gmail.com> wrote:
>>
>> On Sun, Jun 7, 2020 at 2:21 PM David M. Cotter <dave at kjams.com> wrote:
>> i have an example project (see below), that tries 6 different implementations, attempts to make the focus ring 3 pix wide. None of them work on windows, and only one of them PARTIALLY works on mac. What i want is the style you get around a text edit on mac, but i want that style on ALL widgets, and i want it on windows too.
>>
>> anyone have any idea how i can accomplish this?
>>
>> It might be as simple as returning a different value for QStyle::PM_FocusFrameHMargin and QStyle::PM_FocusFrameVMargin in a QStyle::pixelMetric or QProxyStyle::pixelMetric implementaton. If you're using one of the standard styles then it's pretty simple to create and use a QProxyStyle class to tweak pixel metrics and other aspects of the style.
>>
>> If that doesn't work you may be able to reimplement Q[Proxy]Style::drawControl for element QStyle::CE_FocusFrame and handle the drawing of the focus frame itself.
>>
>> One thing to watch out for is that making QStyle::PM_FocusFrameHMargin and QStyle::PM_FocusFrameVMargin larger than default can result in the focus frame getting clipped in some situations. We see this using persistent editors in itemviews sometimes, and I think we also sometimes see this when certain widgets are in splitters.
>>
>> Adam
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
-John
More information about the Interest
mailing list