[Solved] Hiding tab from QTabWidget made in QtCreator



  • Hi,

    I am using QtCreator and have implemented a QTabWidget on my MainWindow. With the designer, I have 4 tabs that all include layouts / a ton of UI elements / etc.

    I haven't been able to figure this out yet but is there a way to "hide" a specific tab if it was created in the designer? I would like to hide and show specific tabs with respect to what the user selects.

    I know if you generate it through code then you can add / remove references to tabs as you please, but unfortunately this isn't really an option for me at this moment in time.

    Thanks.


  • Moderators

    There's no built in method like setTabVisible(false) unfortunately.
    The workaround I often use is applying this stylesheet:
    @
    QTabWidget::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }
    @
    and then using setTabEnabled(false).
    Of course if you also need disabled (grayed out) tabs this method won't work.



  • ahhhhh makes perfect sense. That works great, thank you!



  • [quote author="Krzysztof Kawa" date="1359565812"]There's no built in method like setTabVisible(false) unfortunately.
    The workaround I often use is applying this stylesheet:
    @
    QTabWidget::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }
    @
    and then using setTabEnabled(false).
    Of course if you also need disabled (grayed out) tabs this method won't work.[/quote]

    Nice trick, thanks for posting!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.