The main window of my application is a QWidget with a QGridLayout comprising several other widgets, including a QStatusBar.
I followed the Qt documentation http://doc.qt.io/qt-4.8/qstatusbar.html, so that my status bar is able to display:
- a "normal message" (namely: "Ready"), by way of adding a QLabel to the status bar using
QStatusBar::addWidget(). - temporary messages (that temporarily hide the "normal message"), by calling
QStatusBar::showMessage().
My problem is that when a temporary message is shown on or cleared off the status bar, then it apparently triggers QLayout::activate() (on the layout of my main window). This in turn possibly provokes a resizing of the other widgets in my window, and I do not want that to happen.
The curious (annoying) thing is that the status bar is actually not resized (as it should, it doesn't need to be resized), so I'm not sure why QStatusBar::showMessage() would ask the layout to resize anything.
Anyone knows a solution to this? Thanks in advance!
QLayout::activate()causes other things to resize in spite of all widget sizes supposedly being the same, there's something horribly wrong. You should be able to callactivate()on any layout without any effects at all, as many times as you wish - as long as everything is correct. Are you using any custom widgets? Please produce a minimal, self-contained, single-file test case. - Kuba hasn't forgotten MonicasetGeometryis exclusive: you can do either one, but never both at the same time. Your code is broken and you must fix it first. "I should create my own layout class inheriting QLayout, but that sounds like a lot of work." The very reason that you've posted this question is that you're making life very hard for yourself already. What you've done so far is a bad hack and I'd never pass it in a code review. It will not work properly, it's not meant to, and you're breaking all sorts of invariants by doing things that way. - Kuba hasn't forgotten Monica