[Interest] [QML] Is there a way to implement font.pointSize/font.pixelSize switch?
Eskil Abrahamsen Blomfeldt
Eskil.Abrahamsen-Blomfeldt at qt.io
Tue Apr 14 08:47:04 CEST 2026
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/8b56621e/attachment.htm>
More information about the Interest
mailing list