Results 1 to 3 of 3

Thread: setTabsClosable just for few tabs

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question setTabsClosable just for few tabs

    Can I setTabsClosable just for few tabs ? I mean close button not show in all tabbar on QTabWidget.
    Can I use stylesheet for hide few close button ?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setTabsClosable just for few tabs

    Qt doesn't support this, but you can try use next:
    1. get QTabWidget's tab bar, like this
    Qt Code:
    1. QTabBar *tabBar = m_tabWidget->findChild<QTabBar *>();
    To copy to clipboard, switch view to plain text mode 
    2. then you can get access to buttons on tabs using QTabBar::tabButton.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Apr 2009
    Location
    Italy
    Posts
    70
    Thanks
    23
    Thanked 15 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setTabsClosable just for few tabs

    You can also subclass QTabWidget and provide a custom member function to hide buttons:

    Qt Code:
    1. MyTabWidget::MyTabWidget(QWidget *parent):
    2. QTabWidget(parent)
    3. {
    4. // ...
    5. setTabsClosable(true);
    6. // ...
    7. }
    8.  
    9. void MyTabWidget::hideCloseButton(int index) // custom member function
    10. {
    11. tabBar()->setTabButton(index, QTabBar::RightSide, 0);
    12. }
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to mattc for this useful post:

    wirasto (21st November 2009)

Similar Threads

  1. Changing names of QTabWidget tabs
    By RThaden in forum Qt Programming
    Replies: 7
    Last Post: 29th January 2019, 21:25
  2. Replies: 2
    Last Post: 23rd July 2012, 08:42
  3. Squeezing MdiArea tabs
    By truefusion in forum Qt Programming
    Replies: 0
    Last Post: 1st March 2009, 12:21
  4. How to make "west" tabs horizontal?
    By plumbum in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2007, 10:32
  5. Removing Tabs
    By NewGuy in forum Qt Programming
    Replies: 6
    Last Post: 22nd July 2006, 22:46

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.