I want to have moveable multicolor tooltip for QGraphicsItems. For example when I click on graphicsItem in scene, tooltip appears, then during dragging mouse tooltip should follow cursor. I can implement movable tooltip with standard QToolTip, but seems Qt support only 1 color for whole tooltip. Also QToolTip doesn't have paintEvent, so I decide to create ColoredTooltip class inherited from QTextEdit, but problem appears when I show at first time ColoredTooltip object. It began to grab mouse events, which is not ok for me, because I can't catch mouseMove events for graphics scene and move coloredTooltip. How can I solve that problem?
相关问题
- Sorting 3 numbers without branching [closed]
- QML: Cannot read property 'xxx' of undefin
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- How to get a Component's own ElementRef for re
- Selecting only the first few characters in a strin
To color single words (or any part of a text) use Qt's tiny HTML subset supported by its rich text engine. The
<font>
tag and the attributecolor=
are supported.QToolTip
supports rich text.This one works for me:
To use any RGB color (not only known names), use the hex-notation:
Note that unless you need to move the tool tip while being shown or want to set additional properties, you can simply use
QGraphicsItem::setToolTip
.