How can I associate spans of text in a QTextEdit with specific objects to be returned when a sure clicks on them?

inhahe inhahe at gmail.com
Wed Mar 31 08:33:35 BST 2021


I'm making an IRC client, and I want to make it so that, when the user
right clicks or double clicks on a person's nick in the channel scroll
(where it says whom a message is from), the click function is able to tell
(a) that they clicked on a nick, and (b) what the nick is. So I guess I
need to attach objects or ints or something to those spans, but I don't
know how..

I thought of insertHtml('<span class="nick">some_nick</span>'), but I
wouldn't know how to retrieve the class of the span clicked on or the
contents of the span.

I found 'virtual void insertParagraph ( const QString & text, int para )'
and 'void QTextEdit::clicked ( int para, int pos ) [signal]', which seem to
be what I need (except I'd need right click and double click instead), but
they only seem to be available in Qt, not PyQt.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210331/51111fa8/attachment.htm>


More information about the PyQt mailing list