Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change background color of balloon message for QSystemTrayIcon

How to change background color of balloon message for QSystemTrayIcon

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 5.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qttrekker
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qttrekker
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        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.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qttrekker
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

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

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved