How to change background color of balloon message for QSystemTrayIcon



  • How can I apply stylesheet rules to the balloon message that is displayed using the QSystemTrayIcon::showMessage() function? My main goal is to simply change the background color but I'd also like to be able to modify the border and font and use a custom image for the close button.

    @
    QSystemTrayIcon::message {
    background:rgb(85, 84, 120);
    border:1px solid rgb(79, 79, 79);
    font-size:10px;
    color:rgb(0, 0, 0);
    image: url(:/images/close-button.png);
    }
    @

    [edit: code highlighted / Denis Kormalev]



  • Does anyone know how to apply the css rules above to a balloon tip? Obviously the code above doesn't work and I've also tried applying those rules to QBalloonTip but it doesn't have any visible effect either.



  • I doubt the ballon message is stylable at all.

    On Windows system function Shell_NotifyIcon() is used
    On Mac OS X "growl":http://growl.info/ (a 3rdparty framework) is used
    Only on Linux and WinCE the balloon seems to be drawn by Qt itself.



  • The application I'm developing will only be used on Linux so it won't matter if it's not cross-platform compatible. I've looked at the source of the QBalloonTip class and it appears that the background is set with the code below.
    @
    QPalette pal = palette();
    pal.setColor(QPalette::Window, QColor(0xff, 0xff, 0xe1));
    pal.setColor(QPalette::WindowText, Qt::black);
    setPalette(pal);
    @

    How can I replace the QBalloonTip constructor with my own code? I've tried to reimplement the QSystemTrayIcon::showMessage function but to do so I would also need to reimplement QSystemTrayIconPrivate::showMessage_sys and QBalloonTip::showBalloon. Unfortunately I'm not entirely sure how to accomplish this.



  • No need to reimplement QSystemTrayIconPrivate, just copy it's stuff to your own method and use a subclass or modified copy of QBalloonTip.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.