Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

setTabsClosable(true) with exception to one?



  • I have a QTabWidget with several tabs and I've setTabsClosable() and connected the TabCloseRequested() signal to a slot.

    mainTabs = new QTabWidget;
    mainTabs->setTabBarAutoHide(true);
    mainTabs->setTabsClosable(true);
    
    // ...
    connect(mainTabs, &QTabWidget::tabCloseRequested,
        this, &MainWindow::closeTabs);
    

    All of the tabs show an X so that I can click it on the tab of choice and it will close.

    However, I'd like to know if there is one tab (at my index 0) that can be set to where no X will show as I must have at the very least this one tab always showing. It must not be allowed to close or show the X.

    Anyone have ideas?



  • @SRaD said in setTabsClosable(true) with exception to one?:

    mainTabs->setTabBarAutoHide(true);
    mainTabs->setTabsClosable(true);

    This below line will get the tabbutton from the tabbar at index 0 and hides it.

    mainTabs->tabBar()->tabButton(0,QTabBar::RightSide)->hide();


Log in to reply