Quick Tip: Customize Qt Tooltips with Style Sheets

I’ve been working on an application recently, and I was utilizing a custom version of Qt’s Fusion style. I got the theme looking really sleek, but then I noticed the ugly tooltips. :/ I knew there had to be a way to do this! I spent about 2 minutes thinking and searching the Qt Documentation before I realized that there was such a thing as style sheets in Qt! 😛

It’s one of those things that I had never really used just because I hadn’t bothered. That figures… anyway, style sheets are extremely helpful when you want to customize the look and feel of your application. In this case, we’ll change some attributes of the QToolTip.

    qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");

This style results in a tool tip looking something like this:

Custom Tooltip

Create a custom tooltip using Qt Style Sheets

You can certain style it differently using the CSS-like properties. 😉


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s