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. Hide an Icon in a Tab
Qt 6.11 is out! See what's new in the release blog

Hide an Icon in a Tab

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 815 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.
  • L Offline
    L Offline
    leinad
    wrote on last edited by
    #1

    Hi,

    I have a tabWidget where I added an icon to a tab which was very simple to do. The problem is when the user clicks on the tab I change the text on the tab but I also would like to hide the icon. I did subclass QTabWidget and QTabBar so I do have a paintEvent capability if I need it. Can someone explain to me how I can hide the icon or remove it, either is okay. I searched hi and low but there doesn't seem to be any threads on the subject.

    Any help is appreciated.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      So how did you add it?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leinad
        wrote on last edited by
        #3

        QIcon icon(":Warning.gif");
        customTabWidget_->setTabText(alertsTabIndex_, "* Alerts *"); //add the text
        customTabWidget_->setTabIcon(alertsTabIndex_, icon); //add the icon

        But how can I hide or remove it if I need to?

        jsulmJ 1 Reply Last reply
        0
        • L leinad

          QIcon icon(":Warning.gif");
          customTabWidget_->setTabText(alertsTabIndex_, "* Alerts *"); //add the text
          customTabWidget_->setTabIcon(alertsTabIndex_, icon); //add the icon

          But how can I hide or remove it if I need to?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @leinad said in Hide an Icon in a Tab:

          But how can I hide or remove it if I need to?

          Did you try to set a null icon if you want to hide the icon?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • L Offline
            L Offline
            leinad
            wrote on last edited by
            #5

            No, how would I do that?
            QIcon icon(NULL);
            customTabWidget_->setTabIcon(alertsTabIndex_, icon);

            Would this work?

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by Christian Ehrlicher
              #6

              QIcon(NULL) will not compile

              Simply pass an empty QIcon() to setTabIcon()

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              2
              • L Offline
                L Offline
                leinad
                wrote on last edited by
                #7

                Ok, let me try .

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  leinad
                  wrote on last edited by
                  #8

                  Works great! Thanks.

                  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