Adding a tooltip in QPlainTextEdit
-
Well i've got a way to do this, however i "don't like it". I'm trying to find out a way to make a QToolTip when you put the mouse over some text (reading that text, obviously.) in a QPlainTextEdit. My way works like that, just that i select the text under cursor by doing cursor.select(), and if i move the mouse outside the text the tooltip stays there until i go to another word.
-
I do not know QPlainTextEdit that much but maybe you can try with "cursorForPosition()":http://developer.qt.nokia.com/doc/qt-4.8/qplaintextedit.html#cursorForPosition? And then with the QTextCursor you can get the block underneath.
-
I think a better approach is to listen to tooltip events, and then set the widgets tooltip dynamically when the event is received, depending on the pointer position. There is some reference here: http://developer.qt.nokia.com/doc/qt-4.8/widgets-tooltips.html
-
Hm, i see. So that's the only way, thanks. :)