Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Width of QStatusBar
Ailurus last edited by Ailurus
I'm wondering how to change the width of my QStatusBar such that it has the same width as my QMainWindow (which contains a Horizontal Layout using certain margins, might be relevant to mention this).
Part of the code:
statusBar(); GeneralInfo = new QLabel("[General Info]"); GeneralInfo->setAlignment(Qt::AlignCenter); statusBar()->addPermanentWidget(GeneralInfo, 1); MeshInfo = new QLabel(""); MeshInfo->setAlignment(Qt::AlignCenter); statusBar()->addPermanentWidget(MeshInfo, 1); statusBar()->setStyleSheet(QString("margin-right: 0px; padding: 6px;"));
Result (at runtime):
I get similar results when leaving out the last line of code (using the style sheet). When maximizing the window, the width of the QStatusBar is correct (with or without the code shown above).
One other attempt to solve the issue:
width()returns the width of my QMainWindow. No luck though. Any ideas?
The corner space is occupied by a resize handle. It's not visible in your theme but you can use this stylesheet to see it clearly:
statusBar()->setStyleSheet("margin-right: 0px; padding: 6px; border: 1px solid red;");
Maximized window has no resize handle so that's why the issue goes away.
If you don't want the resize handle you can disable it with
Ailurus last edited by
Thanks! Problem solved :).