Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. setTabsClosable(true) with exception to one?
Qt 6.12 LTS is out! See what's new in the release blog

setTabsClosable(true) with exception to one?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 558 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SRaD
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • nageshN Offline
      nageshN Offline
      nagesh
      wrote on last edited by
      #2

      @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();

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved