[Interest] [QML] Is there a way to implement font.pointSize/font.pixelSize switch?
Alexander Dyagilev
alervdvcw at gmail.com
Tue Apr 14 15:04:05 CEST 2026
Thank you for the responses! It works.
On Tue, Apr 14, 2026 at 1:47 PM Eskil Abrahamsen Blomfeldt <
Eskil.Abrahamsen-Blomfeldt at qt.io> wrote:
> Hi!
>
> You could replace the whole font object instead of only the size
> properties. Something like this:
>
> Label {
> text: "TEST"
> font: cb.checked ? ({pixelSize: 13}) : ({pointSize: 13})
> }
>
>
>
> --
> Eskil Abrahamsen Blomfeldt
> Principal Manager, Graphics Engines
>
> The Qt Company
> Sandakerveien 116
> 0484 Oslo, Norway
> eskil.abrahamsen-blomfeldt at qt.io
> http://qt.io
>
> Public
> ------------------------------
> *From:* Interest <interest-bounces at qt-project.org> on behalf of Alexander
> Dyagilev <alervdvcw at gmail.com>
> *Sent:* Monday, April 13, 2026 5:12 PM
> *To:* Qt Project <interest at qt-project.org>
> *Subject:* [Interest] [QML] Is there a way to implement
> font.pointSize/font.pixelSize switch?
>
> Hello,
>
> This code can only switch a Label to use font.pixelSize from
> font.pointSize and can't switch it back.
>
> Is there a way to make it work? In other words, how do I reset
> font.pixelSize to an undefined value so it will use font.pointSize again?
>
> Label {
> text: "TEST"
> font.pointSize: cb.checked ? 0 : 13
> font.pixelSize: cb.checked ? 13 : 0
> }
>
> CheckBox {
> id: cb
> text: "Use font.pixelSize"
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20260414/4b5b0bba/attachment.htm>
More information about the Interest
mailing list