Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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>
    </p>
        )").arg(mudlet->mDiscord.getDetailText(mpHost));
        checkBox_discordServerAccessToDetail->setToolTip(tooltip);
    

    How it looks:
    alt text

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


  • Lifetime Qt Champion

    Hi
    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

    @Vadi2
    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