Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to change background color of balloon message for QSystemTrayIcon

    General and Desktop
    2
    5
    4919
    Loading More Posts
    • 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
      qttrekker last edited by

      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 Reply Quote 0
      • Q
        qttrekker last edited by

        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 Reply Quote 0
        • G
          goetz last edited by

          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 Reply Quote 0
          • Q
            qttrekker last edited by

            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 Reply Quote 0
            • G
              goetz last edited by

              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 Reply Quote 0
              • First post
                Last post