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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:25:54+00:00 2026-05-20T09:25:54+00:00

I am subclassing QTabWidget to add a QTabBar , who’s tabs stretch over the

  • 0

I am subclassing QTabWidget to add a QTabBar, who’s tabs stretch over the whole width of the tabBar. Therefore I am setting the expanding property to true. This doesn’t seem to change anything about the behavior of the tabs.

Did anyone encounter the same problem? I use Qt 4.6 in combination with

TabWidget::TabWidget(QWidget *parent)
{
    tabBar = new QTabBar(this);
    tabBar->setIconSize(QSize(160,160));
    tabBar->setExpanding(true);
    setTabBar(tabBar);
}

EDIT: has been solved, here is how I implemented it, in case anyone is interested:

    tabBar = new QTabBar(this);
    tabBar->setExpanding(true);
    layout = new QVBoxLayout(this);
    setLayout(layout);
    stackedLayout = new QStackedLayout();
    layout->addWidget(tabBar);
    layout->addLayout(stackedLayout);
    connect(tabBar, SIGNAL(currentChanged(int)), stackedLayout, SLOT(setCurrentIndex(int)));

void MainWindow::addTab(QWidget *widget, const QIcon &icon, const QString &label) {
    tabBar->addTab(icon, label);
    stackedLayout->addWidget(widget);
}
  • 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-05-20T09:25:54+00:00Added an answer on May 20, 2026 at 9:25 am

    From the QTabBar source code:

    // ... Since we don't set
    // a maximum size, tabs will EXPAND to fill up the empty space.
    // Since tab widget is rather *ahem* strict about keeping the geometry of the
    // tab bar to its absolute minimum, this won't bleed through, but will show up
    // if you use tab bar on its own (a.k.a. not a bug, but a feature).
    

    To get around this “feature”, you can create your own tab widget using a QTabBar above a widget with a QStackedLayout.

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

Sidebar

Related Questions

I am having a issue subclassing MKPolygon . I want to add a simple
While subclassing db.models.Model , sometimes it's essential to add extra checks/constraints. For example, I
Is it possible to add a UILabel to a CALayer without subclassing and drawing
Question about subclassing in matlab, under the new class system. I've got class A
I'm subclassing QProgressBar in a custom widget, and I overwrote the paintEvent method with
I'm subclassing NSUserDefaults in my application. A side effect of this is I can't
If one can prevent subclassing by declaring private constructor in the base class, why
I'm subclassing UITableViewCell and adding two subviews (image, UILabel). When the row is touched.
I'm contemplating subclassing UIScrollView (the way UITextView does) to draw a fairly large amount
Possible Duplicate: Subclassing UIView to draw in Quartz Hello i am searching good example

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.