How to control TabBar width in MdiSubwindow
General and Desktop
4
Posts
2
Posters
4.7k
Views
1
Watching
-
I would like to title text in tabbed view mode of MDI subwindow to adjust to text length. Currently, it is too wide.
-
You can get hold of the underlying tabbar and call setExpanding(false) on it, see the "documentation":http://doc.qt.nokia.com/latest/qtabbar.html#expanding-prop
The following example illustrates how this can be done:
@
#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow window;QMdiArea *area = new QMdiArea(&window); area->setViewMode(QMdiArea::TabbedView); QMdiSubWindow *first = area->addSubWindow(new QLineEdit(area)); first->setWindowTitle("First"); QMdiSubWindow *second = area->addSubWindow(new QLineEdit(area)); second->setWindowTitle("Second"); window.setCentralWidget(area); QList<QTabBar *> tabBarList = area->findChildren<QTabBar*>(); QTabBar *tabBar = tabBarList.at(0); if (tabBar) { tabBar->setExpanding(false);
}
window.show();
return app.exec();
}
@
Does this give you the result you are looking for? -
I found that tabBar is accessible. However, visual result did not change after expanding() is set to false.