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. [SOLVED]How to hide tab's label
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]How to hide tab's label

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.3k 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
    mbnoimi
    wrote on last edited by
    #1

    Howdy,

    I'm adding tabs to QTabWidget as following:

    @ui->tabWidget_sidebar->addTab(page, "");@

    How can I hide label's tab?

    I've to hide it because I want to show QTabWidget with icons only .

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you try to add a tab with an icon and empty string ?

      If it still doesn't fit your need, you will have to subclass QTabBar to make it look like you want.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mbnoimi
        wrote on last edited by
        #3

        bq. Did you try to add a tab with an icon and empty string ?

        yes

        bq. If it still doesn’t fit your need, you will have to subclass QTabBar to make it look like you want.

        Currently it works fine without subclassing, even if I subcalss it I've a problem with showing the tabs because the tab keeps some space for the label even if it's empty

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then you would have to reimplement the paint event to draw only the icon

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbnoimi
            wrote on last edited by
            #5

            [quote]
            Then you would have to reimplement the paint event to draw only the icon
            [/quote]

            Thank you, Any hint?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What hint are you looking for ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbnoimi
                wrote on last edited by
                #7

                [quote]What hint are you looking for ?[/quote]

                I wanted to know how reimplement the paint event to draw only the icon (as you suggested).

                Any way, Thank you I fixed this issue by using stylesheet as following:
                [code]QTabBar::tab {
                background-color: rgb(0, 0, 0, 0);
                padding: 2px;
                border: 2px;
                text-align: center;
                height: 64px;
                width: 64px;
                }[/code]

                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