I currently have a QTabWidget and some layout. Now I want all the tabs of my QtabWidget to occupy the width of the QtabWidget so I have something like this. The following method expands the two tabs in my Qtabwidget so they are the same size as the QtabWidget
void Contacts::AdjustTabs( int pos, int index )
{
std::string orig_sheet = ui.tabWidget->styleSheet().toStdString();
QString new_style = QString("QTabBar::tab { width: %1px; } ").arg((ui.tabWidget->size().width() /ui.tabWidget->count()));
std::string t = new_style.toStdString();
orig_sheet = orig_sheet + t;
ui.tabWidget->setStyleSheet(orig_sheet.c_str());
}
The above method works fine. Now the problem starts when the QTabwidget is set in a Qsplitter layout along with some other layout.At startup construction the above method does not seem to work for instance I have something like this
Someclass::SomeConstructor()
{
ui.setupUi(this);
.........
QObject::connect(ui.splitter,SIGNAL(splitterMoved(int,int)),this,SLOT(AdjustTabs(int,int)));
AdjustTabs(0,0);
}
Now when the form appears the horizontal size of the tabs remain unchanged (they do not expand - which is wrong). However when i move the splitter the tabs expand and everything is fine. My question is how can I make my tabs expand during form load ? Why arent they expanding ?