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] Hiding tab from QTabWidget made in QtCreator
Forum Updated to NodeBB v4.3 + New Features

[Solved] Hiding tab from QTabWidget made in QtCreator

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 14.7k 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.
  • V Offline
    V Offline
    vezprog
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vezprog
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          [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!

          K 1 Reply Last reply
          0
          • A andre

            [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!

            K Offline
            K Offline
            Klo_
            wrote on last edited by
            #5

            Dunno if there is a change in the code, but the CSS is applied only with :

            QTabBar::tab:disabled {
            width: 0;
            height: 0;
            margin: 0;
            padding: 0;
            border: none;
            }

            (and no QTabWidget::tab)

            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