Skip to content
0:00 / 0:00

#qt#qtooltip#gui

C++ Qt 59 - ToolTips with HTML styling and images from resources

VoidRealms

85K subscribers • 1 video on Hallway

YouTube
  • Recommended by 1 person: 1 on Stack Overflow and its sister sites.
  • May be out of date. The tools, versions or practices it shows have likely moved on.

Intermediate. Assumes working knowledge.

35K views15 years ago1 recommendation

Programming languagesC++

Why it's here

1 person recommends this

What people say. Recommended as a practical demonstration of embedding images and HTML styling inside Qt tooltips.

Antonio Diason Stack Overflow • Recommends

On “Use a picture or image in a QToolTip”

You can easily show images with the following html code: QToolTip::showText(QCursor::pos(), "<img src=':/icon.png'>Message", this, QRect(), 5000); This example will show a tooltip with the image from Qt resources and the text for 5 seconds. For more details, you can see this video: link to this video Edit1: If you want to show an image from memory, you can save the QImage/QPixmap to memory (preferably using some lossless compression like PNG) and convert it to base 64 and load it with the html code, like this: QImage icon = QImage(10, 10, QImage::Format_ARGB32); icon.fill(QColor(255, 0, 0, 100)); QByteArray data; QBuffer buffer(&data); icon.save(&buffer, "PNG", 100); QString html = QStrin…