Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED]How to hide tab's label



  • 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 .


  • Lifetime Qt Champion

    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.



  • 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


  • Lifetime Qt Champion

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



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

    Thank you, Any hint?


  • Lifetime Qt Champion

    What hint are you looking for ?



  • [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]


Log in to reply