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 add red color icon to Status of Mainwindow
QtWS25 Last Chance

How to add red color icon to Status of Mainwindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.4k 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
    Qt Enthusiast
    wrote on last edited by
    #1

    How to add red color icon to Status of Mainwindow

    if (condition)
    add red color icon to status bar
    ele
    add green color icon to status bar

    can someone help me to write code for it

    mrjjM 1 Reply Last reply
    0
    • Q Qt Enthusiast

      How to add red color icon to Status of Mainwindow

      if (condition)
      add red color icon to status bar
      ele
      add green color icon to status bar

      can someone help me to write code for it

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Qt-Enthusiast
      You can use a QLabel with stylesheet or red pixmap and use
      http://doc.qt.io/qt-5/qstatusbar.html#addWidget

      1 Reply Last reply
      2
      • T Offline
        T Offline
        TobbY
        wrote on last edited by
        #3

        Hi,
        For stylesheet refer the @mrjj link

        to embed QLabel to statusbar:

        QLabel *colorLabel  = new QLabel(this);
        ui->statusBar->addPermanentWidget(colorLabel);
        
        1 Reply Last reply
        1
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          how to edit it to Green color

          mrjjM 1 Reply Last reply
          0
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on last edited by
            #5

            I do not have eqrc

            1 Reply Last reply
            0
            • Q Qt Enthusiast

              how to edit it to Green color

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Qt-Enthusiast
              You mean change from red to green?

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                Qt Enthusiast
                wrote on last edited by
                #7

                yes and how to create the icon small circile when I do not qrc

                mrjjM 1 Reply Last reply
                0
                • Q Qt Enthusiast

                  yes and how to create the icon small circile when I do not qrc

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Qt-Enthusiast
                  you get get red box with
                  QPixmap pix(32,32);
                  pix.fill(Qt::red);
                  ui->label->setPixmap(pix);

                  and if u hold on to the label pinter u can at any time create new
                  and set the pixmap again.

                  1 Reply Last reply
                  1
                  • T Offline
                    T Offline
                    TobbY
                    wrote on last edited by TobbY
                    #9

                    Hi,

                    To change to green.red without resource.
                    ```
                    label->setFixedSize(20,20); // Make a square label, radius is half of this size

                    if (yes) {
                        label->setStyleSheet("background-color: green; border-radius: 10px;"); // Change radius according to ur label size
                    } else {
                        label->setStyleSheet("background-color: red; border-radius: 10px;");
                    }
                    
                    1 Reply Last reply
                    3

                    • Login

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