Results 1 to 8 of 8

Thread: Switching off all tabs in QTabWidget

  1. #1
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question Switching off all tabs in QTabWidget

    Hello all,
    I had implemented my own vertical tabwidget for Qt3.3 using QPushButton & QWidgetStack and had given the option to switch off all tabs i.e all tabbuttons could be off at a time(hiding the widgetstack). This behaviour was mimicked from KDevelop and KMdi.
    But I recently updated myself to Qt4.1( aslo experimenting with Qt4.2) and came across QTabWidget::setTabPosition() which supports vertical tabbars.
    But the problem is I am unable to turn off all tabs
    I want the the widget(in tabwidget) to be hidden and all tabs to be turned off when an active tab is clicked again.

    So how can I subclass QTabWidget and get the above functionality ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Switching off all tabs in QTabWidget

    Qt Code:
    1. void SomeClass::on_tabWidget_currentChanged( int currentIndex )
    2. {
    3. static int prevIndex = -1;
    4. QWidget *prev = _ui.tabWidget->widget( prevIndex );
    5. if( prev != 0 ) {
    6. prev->setEnabled( false );
    7. }
    8.  
    9. QWidget *current = _ui.tabWidget->widget( currentIndex );
    10. if( current != 0 ) {
    11. current->setEnabled( true );
    12. }
    13.  
    14. prevIndex = currentIndex;
    15. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 30th August 2006 at 13:03.

  3. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Switching off all tabs in QTabWidget

    Hi Jacek, thanks for your immediate reply but I didn't get what I wanted. I tried your code but it behaves as normal QTabWidget.
    May be the 2 screenshots will help
    tab1.png : With one of tab chosen
    tab2.png : With all tabs off
    Attached Images Attached Images

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Switching off all tabs in QTabWidget

    OK, now I see what you mean by "off". Unfortunately in QTabWidget one of the tabs is always active, so to do this you will have to use QStackedWidget and some custom widget that will imitate the tab bar.

  5. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Switching off all tabs in QTabWidget

    Hi Jacek,
    Thats why I had to come with custom code.
    But anyway , can't all tabs be made to be inactive even in QTabBar ?

    Is any improvements ,about this, going on in Qt4.2 ?
    Last edited by Gopala Krishna; 30th August 2006 at 15:57.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Switching off all tabs in QTabWidget

    Quote Originally Posted by Gopala Krishna
    can't all tabs be made to be inactive even in QTabBar ?
    Unfortunately not, it always has one of the tabs active.

    Actually you are after a bit different widget --- something like KMdiDockContainer.

  7. #7
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Switching off all tabs in QTabWidget

    Thanks for your reply.

    Actually you are after a bit different widget --- something like KMdiDockContainer.
    But unfortunately I am only after Qt only solution.

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

    Default Re: Switching off all tabs in QTabWidget

    1. you can look for the QStackedWidget and hide it on demand. See the assistant code for some details (look to the tab widget implementation in that application)
    2. ideality -> http://www.qtcentre.org/forum/f-qt-s...rary-3286.html

Similar Threads

  1. Replies: 2
    Last Post: 23rd July 2012, 09:42
  2. Dynamically adding tabs
    By larry104 in forum Qt Programming
    Replies: 7
    Last Post: 26th July 2006, 21:27
  3. Removing Tabs
    By NewGuy in forum Qt Programming
    Replies: 6
    Last Post: 22nd July 2006, 23:46
  4. Corner widget in QTabWidget doesn't show up
    By ePharaoh in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2006, 18:02
  5. Qt's optimized OpenGL context switching
    By sverhoff in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 17:40

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.