Results 1 to 3 of 3

Thread: QTabWidget -> closing 1st tab unexpectedly closes all tabs

  1. #1
    Join Date
    May 2009
    Posts
    20
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QTabWidget -> closing 1st tab unexpectedly closes all tabs

    I have a QTabWidget setup with close buttons on each tab. It works fine as I dynamically add and remove tabs except for clicking close on whichever is the first tab. Doing so causes all tabs to close. Anyone have an idea why this might be happening?

  2. #2
    Join Date
    Nov 2008
    Posts
    142
    Thanks
    3
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget -> closing 1st tab unexpectedly closes all tabs

    Please supply the code that you are using. Without that, we can't but guess what is wrong with your approach...

  3. #3
    Join Date
    May 2009
    Posts
    20
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTabWidget -> closing 1st tab unexpectedly closes all tabs

    I didn't post code originally since I was simply using basic functions but here it is anyways:
    Qt Code:
    1. graphTabs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    2.  
    3. graphTabs->setMovable(true);
    4. graphTabs->setTabShape(QTabWidget::Rounded);
    5. graphTabs->setTabPosition(QTabWidget::North);
    6. graphTabs->setTabsClosable(true);
    7. graphTabs->setMinimumWidth(500);
    8. graphTabs->setContentsMargins(0,0,0,0);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. connect(graphTabs, SIGNAL(tabCloseRequested(int)),this,SLOT(hideTab(int)));
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MainWindow::hideTab(int tab_index)
    2. {
    3. graphTabs->removeTab(tab_index);
    4. }
    To copy to clipboard, switch view to plain text mode 

    All tabs are added like this:
    Qt Code:
    1. graphTabs->addTab(rawPage->graphs,"&Raw Data");
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Changing names of QTabWidget tabs
    By RThaden in forum Qt Programming
    Replies: 7
    Last Post: 29th January 2019, 21:25
  2. QTabWidget with same tabs
    By Djony in forum Qt Programming
    Replies: 20
    Last Post: 24th December 2011, 12:20
  3. Replies: 7
    Last Post: 8th April 2009, 08:42
  4. Replies: 1
    Last Post: 16th January 2009, 15:48
  5. Switching off all tabs in QTabWidget
    By Gopala Krishna in forum Qt Programming
    Replies: 7
    Last Post: 30th August 2006, 17:10

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.