aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <[email protected]>2025-04-25 14:37:27 +0200
committerShawn Rutledge <[email protected]>2025-04-29 21:08:27 +0200
commit17a225f09ac5ec7ebd065197917ddd9586571ec1 (patch)
treea3ed48f4af9166ed058cc374dbd23d9d569473c1
parent7824b0b3f3bbb86ce4a1b23551d15c35c441ff1b (diff)
TextEditor example: allow setting multiple font attributes
When a user activates the boldAction for example, the code was replacing QTextCharFormat's font with a default-constructed font that has the bold attribute set, which meant that it could not be bold, italic, underlined struck out, and with a custom size and color at the same time. On the other hand, when we do it the current way: textArea.cursorSelection.font.bold = checked we call QQuickTextSelection::font(), QFont::setBold(), and then QQuickTextSelection::setFont(). (QFont is a QML value type, so it's the only way.) Perhaps at some point, something was going wrong with that, but it seems to work now. Amends 045f9ce192d841f3cc36d514b5f238b46488b41e Fixes: QTBUG-136250 Pick-to: 6.8 6.9 Change-Id: I268e5814e7aa52aeb5aaec2d1a8fbfbc0d670236 Reviewed-by: Oliver Eftevaag <[email protected]>
-rw-r--r--examples/quickcontrols/texteditor/qml/texteditor.qml8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/quickcontrols/texteditor/qml/texteditor.qml b/examples/quickcontrols/texteditor/qml/texteditor.qml
index d75827bb1a..25432e676b 100644
--- a/examples/quickcontrols/texteditor/qml/texteditor.qml
+++ b/examples/quickcontrols/texteditor/qml/texteditor.qml
@@ -81,7 +81,7 @@ ApplicationWindow {
shortcut: StandardKey.Bold
checkable: true
checked: textArea.cursorSelection.font.bold
- onTriggered: textArea.cursorSelection.font = Qt.font({ bold: checked })
+ onTriggered: textArea.cursorSelection.font.bold = checked
}
Action {
@@ -90,7 +90,7 @@ ApplicationWindow {
shortcut: StandardKey.Italic
checkable: true
checked: textArea.cursorSelection.font.italic
- onTriggered: textArea.cursorSelection.font = Qt.font({ italic: checked })
+ onTriggered: textArea.cursorSelection.font.italic = checked
}
Action {
@@ -99,7 +99,7 @@ ApplicationWindow {
shortcut: StandardKey.Underline
checkable: true
checked: textArea.cursorSelection.font.underline
- onTriggered: textArea.cursorSelection.font = Qt.font({ underline: checked })
+ onTriggered: textArea.cursorSelection.font.underline = checked
}
Action {
@@ -107,7 +107,7 @@ ApplicationWindow {
text: qsTr("&Strikeout")
checkable: true
checked: textArea.cursorSelection.font.strikeout
- onTriggered: textArea.cursorSelection.font = Qt.font({ strikeout: checked })
+ onTriggered: textArea.cursorSelection.font.strikeout = checked
}
Action {