PyQt6 Not toggling "bold" text.
Ovid
curtis.poe at gmail.com
Fri Jan 26 12:26:19 GMT 2024
On Fri, Jan 26, 2024 at 1:20 PM Charles <peacech at gmail.com> wrote:
> You probably should also use `charFormat` from the cursor not from the
> `textEditor()`.
>
> fmt.setFontWeight(QFont.Weight.Bold if c.charFormat().fontWeight() !=
> QFont.Weight.Bold else QFont.Weight.Normal)
>
>>
I rewrote it as this:
def setBoldText(self):
fmt = QTextCharFormat()
cursor = self.textEditor.textCursor()
fmt.setFontWeight(QFont.Weight.Bold if
cursor.charFormat().fontWeight() != QFont.Weight.Bold else
QFont.Weight.Normal)
cursor.setCharFormat(fmt)
However, the bug remains. Thanks, though!
Best,
Ovid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240126/872f11da/attachment.htm>
More information about the PyQt
mailing list