Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:06:21+00:00 2026-06-11T09:06:21+00:00

I am making a GUI program in Qt. I have one tab and in

  • 0

I am making a GUI program in Qt.

I have one tab and in that tab there is push button, what I want is when that button is clicked then it should open a tab in the same widget and it should be closable.
How can I do that? A example code will be good.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:06:22+00:00Added an answer on June 11, 2026 at 9:06 am

    I do not fully understand the question, but here is my best attempt at answering it. I suppose that you use QTabWidget for your tabs. You can add a widget and select it by the following code:

    QWidget* widget;
    int index = ui->tabWidget->addTab(widget, "Description");
    ui->tabWidget->setCurrentIndex(index);
    

    You cannot make single tabs closable, but you can intercept the close event:

    ui->tabWidget->setTabsClosable(true);
    connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
    

    And handle unwanted close events like this:

    void MainWindow::closeTab(int index)
    {
        if (index == 0)
        {
            return; // don't close the first tab
        }
        QWidget* widget = ui->tabWidget->widget(index);
        ui->tabWidget->removeTab(index);
        delete widget;
    }
    

    EDIT:

    You can insert Tabs with:

    ui->tabWidget->insertTab(index, widget, "Description");
    

    Here is the documentation for the QTabWidget class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello I am very beginer of haskell I am making GUI program that open
I have 2 questions. So i am making a python program that will backup
I want to start making a little window-based program that runs on both Linux
I have a console program written in Java that should respond to single key
I have a problem on a program I'm making that I honestly can't find
I have a GUI program that, in this example, downloads an exe using wget
While making my program i have come across this requirement that i have to
I am using Java Netbeans GUI Builder for making GUI. I want to give
I am making a GUI in OpenGL (more specifically lwjgl). I have tried hard
i have a program that takes some time creating pdf files i would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.