Important: Please read the Qt Code of Conduct -

How to easily set the background colour of a tooltip?

  • I'm playing around with the html and the original colour is still bleeding though. Code:

        QString tooltip = QStringLiteral(R"(
    <p style="background-color: #2F3135">
        <img src=":/icons/discord-rich-presence.png"/>
        <p style="color: #C79698; background-color: #66373A">%1 (detail)</p>

    How it looks:
    alt text

    I'd rather not go the complicated way of having to create my own QToolTip.

  • Lifetime Qt Champion

    Using stylesheet should do it
    qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #000000; border: 0px; }");

    alt text

  • It would, but I don't want to do it for the entire application. I know I can give my widget an ID and only use that, but since I allow my users to skin the application using setStyleSheet, it's gonna be fragile. Any other way?

  • Lifetime Qt Champion

    Ok. if user can skin the app , it will be messy to maintain
    that extra line for QToolTip, i agree.

    Sadly i found no other way to address it.

Log in to reply