PyQt6 Not toggling "bold" text.
Charles
peacech at gmail.com
Fri Jan 26 12:19:47 GMT 2024
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)
On Fri, Jan 26, 2024 at 6:54 PM Ovid <curtis.poe at gmail.com> wrote:
> On Fri, Jan 26, 2024 at 12:05 PM Charles <peacech at gmail.com> wrote:
>
>> Hi,
>>
>> Other than Google and AI, searching code in github is also an
>> alternative: searching for mergeCharFormat yields
>>
>>
>> https://github.com/kovidgoyal/calibre/blob/07f988b109627bdbb88ab4b43ccfa6956276c682/src/calibre/gui2/comments_editor.py#L465
>>
>> From the look of it, your code is missing
>> `self.textEditor.setTextCursor(...)` because `textCursor()` returns a copy.
>>
>>>
> Hi Charles,
>
> I gave that a try:
>
> cursor = self.textEditor.textCursor()
> cursor.setCharFormat(fmt)
> self.textEditor.setTextCursor(cursor)
>
> Sadly, it did not change the behavior. Thanks for the reply, though!
>
> Best,
> Ovid
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240126/0ecf65d5/attachment.htm>
More information about the PyQt
mailing list