Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. Interactive application icon
Forum Updated to NodeBB v4.3 + New Features

Interactive application icon

Scheduled Pinned Locked Moved Unsolved Showcase
8 Posts 4 Posters 326 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mizmas
    wrote last edited by
    #1

    JonBJ DawinchD 2 Replies Last reply
    0
    • M Mizmas

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by
      #2

      @Mizmas At a guess, depends on your platform/window manager?

      M 1 Reply Last reply
      0
      • JonBJ JonB

        @Mizmas At a guess, depends on your platform/window manager?

        M Offline
        M Offline
        Mizmas
        wrote last edited by
        #3

        @JonB It's actually really simple, the application's icon is just an image, so you just need an image representation of a widget, and when that widget changes, you can just update the application's icon like this:

        pixmap = self.slider_frame.grab()
        self.setWindowIcon(QIcon(pixmap))
        

        grab() returns a pixmap, update the pixmap each time the slider moves, set the pixmap as the new icon.
        You can also do the same thing for the tray icon.
        You can also use a QMovie animation, for example

        pixmap = self.animation.currentPixmap()
        

        So if you combine everything, you can have an event driven interactive application icon / system tray icon

        JonBJ 1 Reply Last reply
        0
        • M Mizmas

          @JonB It's actually really simple, the application's icon is just an image, so you just need an image representation of a widget, and when that widget changes, you can just update the application's icon like this:

          pixmap = self.slider_frame.grab()
          self.setWindowIcon(QIcon(pixmap))
          

          grab() returns a pixmap, update the pixmap each time the slider moves, set the pixmap as the new icon.
          You can also do the same thing for the tray icon.
          You can also use a QMovie animation, for example

          pixmap = self.animation.currentPixmap()
          

          So if you combine everything, you can have an event driven interactive application icon / system tray icon

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote last edited by
          #4

          @Mizmas And that would work in, say, GNOME? I thought that just uses a static file for its icon?

          M 1 Reply Last reply
          0
          • JonBJ JonB

            @Mizmas And that would work in, say, GNOME? I thought that just uses a static file for its icon?

            M Offline
            M Offline
            Mizmas
            wrote last edited by
            #5

            @JonB I don't use Linux so IDK

            JonBJ 1 Reply Last reply
            0
            • M Mizmas

              @JonB I don't use Linux so IDK

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote last edited by JonB
              #6

              @Mizmas
              ...which is why I said it would probably depend on your platform/window manager which you didn't say...

              [TBH I had not noticed initially that this was Showcase, I thought you were asking if you could do this from Qt.] Your showcase is fine, just you might like to mention this if it's e.g. Windows-only as Qt is cross-platform.

              1 Reply Last reply
              0
              • GrecKoG Offline
                GrecKoG Offline
                GrecKo
                Qt Champions 2018
                wrote last edited by
                #7

                @JonB using QWindow::setIcon this also works on Gnome/X11.

                rough PoC:

                    QTimer timer;
                    int i = 0;
                    int iconSize = 32;
                    int rectSize = 5;
                    QPixmap pixmap(QSize{iconSize, iconSize});
                
                    timer.start(20);
                    timer.callOnTimeout([&] {
                        pixmap.fill(Qt::transparent);
                        {
                            QPainter painter(&pixmap);
                            painter.drawRect(i, i , rectSize, rectSize);
                        }
                        i = (i + 1) % (iconSize - rectSize + 1);
                        QIcon icon(pixmap);
                        QGuiApplication::setWindowIcon(icon);
                        QGuiApplication::allWindows().first()->setIcon(icon);
                    });
                
                1 Reply Last reply
                0
                • M Mizmas

                  DawinchD Offline
                  DawinchD Offline
                  Dawinch
                  wrote last edited by
                  #8

                  @Mizmas haha, looks funny :)

                  https://ggsel.net/en

                  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