[Interest] how to get 3 pixel focus ring?
Adam Light
aclight at gmail.com
Mon Jun 8 14:18:21 CEST 2020
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200608/6d118321/attachment.html>
More information about the Interest
mailing list