python - fastest way to change texte appearance in a QTextEdit object -
for python3/pyqt4 project, i'm looking fastest way change text appearance of several words in qtextedit object. text not written in html (it's pure text string), read-only , made of several words. each word has special 'attribute' defined in code, defining appearance when word hovered over. the appearance of words sharing same attribute must change when 1 of these words hovered over.
i need speed since :
- i did more or less same program the words' appearance changed when user clicked on them , guess code slow used hover events. (see details below)
- it's python project based on pyqt4, not c++ 1 based on qt.
any appreciated !
more details :
i can see 2 ways achieve goal :
(1) write text in editor, detect word mouse "flies over", other words highlighted , painfully select them, 1 one, inserting html code modify appearance. it's painfully part find complex , slow : there fastest way ?
(2) writing text html 1 , work css since qtexteditor can use them. alas, easy way can't work. perhaps possible "re-load" css of text , use more clever trick ?
i'm wondering possible word under mouse cursor qtextedit.
you said text cannot edited, maybe qtextedit not best possible widget job. create own widget , draw text yourself. know word positions finding word under mouse easy. , when attribute activated or deactivated, can redraw affected words.