I\'m using Qt and I have a QTabWidget setup in the Qt Designer Editor, you can see it in picture 1.
As you can see after Tab4 there is an empty space all t
As I see it, you have two options, depending on what you want to do.
To fill the background with color:
Take advantage of the transparency of that portion of the tab widget.
QWidget *bg = new QWidget( parent );
bg->setAutoFillBackground( true );
QPalette bg_palette = bg->palette();
bg_palette.setColor( QPalette::Window, QColor( "orange" ) );
bg->setPalette( bg_palette );
QHBoxLayout layout = new QHBoxLayout();
layout->setMargin( 0, 0, 0, 0 );
layout->setSpacing( 0 );
bg->setLayout( layout );
QTabWidget *tab_widget = new QTabWidget();
// set up tab_widget however you want...
layout->addWidget( tab_widget );
This makes the bg widget all orange, but since most of the tab widget will draw over the bg widget, you'll only see the orange where the tab widget doesn't draw.
To make the tabs expand:
I thought this would be easier than it is, but you basically have to subclass QTabWidget in order to get access to the tab bar widget it uses.
class ExpandableTabWidget : public QTabWidget
{
Q_OBJECT;
Q_PROPERTY( bool expanding_tabs READ Expanding WRITE SetExpanding );
public:
ExpandableTabWidget( QWidget *parent = NULL ) : QTabWidget( parent )
{
}
bool Expanding() const
{
return tabBar()->expanding();
}
void SetTabsExpanding( bool expanding = true )
{
tabBar()->setExpanding( expanding );
}
};
You would then either need to make your ExpandableTabWidget
class into a plugin and use it in designer, or you could promote your tab widget to be of type ExpandableTabWidget
and set the expanding value in code. If you choose to do the promotion, you won't see the results you want in designer, but you will when you run your program.