Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.0
-
None
Description
The following is a picture of an application I'm writing for basic text editing.
In the above image, the text was selected right to left across the larger font size text, which is point size 22. Instead of showing an expected font size of 22 – since the text selection ends before it winds up on the smaller size text – it reports 8.
The following block of code was used to update the UI to report this. ui.textEdit is a QTextEdit. The top block of code is in a slot to a selectionChanged signal.
QTextCursor cursor = ui.textEdit->textCursor(); auto blockFormat = cursor.charFormat(); if (blockFormat.isValid()) UpdateFontStyle(blockFormat.font()); void UpdateFontStyle(const QFont& f) { ui.boldButton->setChecked(f.bold()); ui.underlineButton->setChecked(f.underline()); ui.italicButton->setChecked(f.italic()); auto t = QString::number(f.pointSize()); // edited for width ui.fontSizeBox->setCurrentIndex(ui.fontSizeBox->findText(t)); ui.fontNameBox->setCurrentFont(QFontInfo(f).family()); }
If the same text is instead selected by going left to right, or the user double clicks in the larger font text "block" (which is conveniently blocking the double click action from selecting the smaller text by the exclamation point), it still reports 22.