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 9065647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:33:24+00:00 2026-06-16T16:33:24+00:00

This is quite odd. Using this code, I am attempting to add a tab

  • 0

This is quite odd.
Using this code, I am attempting to add a tab to a QTabWidget:

void SideWidget::changePanel(SearchablePanel* panel){
    ui->nextButton->setEnabled(false);
    cout << pointer;
    widgetHistory[++pointer] = panel;
    QWidget* widget = panel->getWidget();
    cout << panel->id;
    MainWindow::main->addTab(widget, "nT");
    QTextEdit* thing = new QTextEdit("Test");

    MainWindow::main->addTab(thing, "tabqx");
    this->internalChange(panel);
}

And internalChange:

void SideWidget::internalChange(SearchablePanel *panel){
    cout << "internale change, "+panel->id;
    ui->scrollPanel->setWidget(panel->getWidget());
    ui->prevButton->setEnabled(true);
}

Now, when I add the tab “tabqx” it works, and when I set the scrollPanel’s widget to panel->getWidget() it works. However, when I attempt to add the tab “nT”, it does not work. I am very confused. I should note that panel->getWidget() returns a QWidget, as might be expected. In this instance specifically, it will return a QTextEdit. Also, MainWindow::main is a static QTabWidget.

So my question is, why is the tab “nT” not being added?

  • 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-16T16:33:26+00:00Added an answer on June 16, 2026 at 4:33 pm

    Basically your code does that:

    MainWindow::main->addTab(panel->getWidget(), "nT"); 
    ui->scrollPanel->setWidget(panel->getWidget());
    

    And since a widget can only be at one place at a time, once you add it to the scroll panel, it is removed from the QTabWidget where you just put it.

    However you could create a new QTextEdit that would share the same underlying QTextDocument by using QTextEdit::document()/setDocument().

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

Sidebar

Related Questions

This will be probable quite odd question. But i thought I will give it
This is a very odd, and quite specific question. Ultimately I am trying to
I have a very odd issue trying to run this quite simple C program
I discovered this quite by accident while looking for a file with a number
I have this quite popular problem, but have failed to find a solution that
I've edited this quite a bit and bolded my question at this point. I
Why does this quite simple xquery takes 10min to execute in sql server (the
I've been reading on this quite some time...and i'm puzzled - Can you help
This is quite the pickle... I have a regular HTML form with a couple
This is quite a simple question - although one that is on my mind

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.