Results 1 to 10 of 10

Thread: Hiding a tab in QTabBar widget

  1. #1
    Join Date
    Aug 2008
    Location
    Usa
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Hiding a tab in QTabBar widget

    Hello, all!

    Is it possible to hide particular tab in QTabBar widget instead of removing it from there? Or in order to accomplish such behavior I have to reimplement QTabBar in my own way?

  2. #2
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hiding a tab in QTabBar widget

    Qt Code:
    1. tabBar()->hide();
    To copy to clipboard, switch view to plain text mode 

    it's a widget, you can hide it without any problems. Note this is a protceted method, so you will need to derive QTabWidget to do this.

  3. #3
    Join Date
    Aug 2008
    Location
    Usa
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hiding a tab in QTabBar widget

    elcuco,

    My goal is to hide particular tab in QTabBar but not QTabBar widget in whole.

  4. #4
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hiding a tab in QTabBar widget

    then removeTab() is your friend. IMHO you will need to keep a reference to the contained widget, otherwise you will lose it.

  5. #5
    Join Date
    Aug 2008
    Location
    Usa
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hiding a tab in QTabBar widget

    elcuco,

    In other words, I don`t have any mean to hide tab except to remove it? This produces many inconveniences: for example if I want to show my tab later at the same place - I have to remember its index and properly update it in order to insert it in the same place.

  6. #6
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hiding a tab in QTabBar widget

    I guess you have to write your own class (a subclass of QTabBar) and impelement your hideTab method. Looks like this is the only way.
    I'm a rebel in the S.D.G.

  7. The following user says thank you to lyuts for this useful post:

    erik (22nd October 2008)

  8. #7
    Join Date
    Aug 2008
    Location
    Usa
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hiding a tab in QTabBar widget

    lyuts,

    Thank you, I have came to the same conclusion.

    The only thing that afraid me a little - is need to reimplement Qt standard classes in order to achieve quite minor changes in a behaviour.

  9. #8
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hiding a tab in QTabBar widget

    Well, if it is needed for your project then it is really worth of doing that. Who know, may be in future you'll need it again. Good luck.
    I'm a rebel in the S.D.G.

  10. #9
    Join Date
    Aug 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hiding a tab in QTabBar widget

    I came across this thread looking for how to hide a tab and came to the same conclusion as Erik, but then after looking at more documentation realized that, as Lyuts hinted very subtly earlier that it is through the removeTab() that you "hide" the tab. You can then addTab() later. If it was already included in the ui object, then you can always reference it from there and you don't need to store another reference.

    Just thought I'd thrown in my comment to help any future seekers of the same answer as the removeTab seems to imply that it will be forever removed (despite the thread being 3 years old ).

  11. #10

    Default Re: Hiding a tab in QTabBar widget

    Noremac's simple answer works for me, 6 years later.

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 08:06
  2. How to Open & Close a Widget ?!!
    By Fatla in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2008, 21:39
  3. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 11:35
  4. Hiding the QTabBar of a QTabWidget
    By elcuco in forum Qt Programming
    Replies: 4
    Last Post: 26th March 2007, 15:59
  5. Expanding and hiding a widget
    By Dauntless in forum Newbie
    Replies: 3
    Last Post: 12th December 2006, 07:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.