PDA

View Full Version : QStatusBar height



regular
20th October 2014, 15:34
Hi,

I have a small issue with QStatusBar. It seems to have a bit bigger height than it is supposed to:
10682
Here's the code that creates it:


QToolButton *abt = new QToolButton(this);
abt->setDefaultAction(aboutAction);

QLabel *gridSpacingLabel = new QLabel(tr(" Grid Spacing: 20"));
QLabel *xPosLabel = new QLabel(tr(" X: 640 "));
QLabel *yPosLabel = new QLabel(tr(" Y: 640 "));
QLabel *widthLabel = new QLabel(tr(" Width: 640 "));
QLabel *heightLabel = new QLabel(tr(" Height: 480 "));
QLabel *unsavedDataLabel = new QLabel();
QPixmap pixmap(":changes.png");
unsavedDataLabel->setPixmap(pixmap);

statusBar()->addPermanentWidget(abt);
statusBar()->addPermanentWidget(gridSpacingLabel);
statusBar()->addPermanentWidget(xPosLabel);
statusBar()->addPermanentWidget(yPosLabel);
statusBar()->addPermanentWidget(widthLabel);
statusBar()->addPermanentWidget(heightLabel);
statusBar()->addPermanentWidget(unsavedDataLabel);


I tried the following (separately) and other sizePolicy combinations but none seem to remove that strip at the top.

statusBar()->setMaximumHeight(20);
statusBar()->layout()->setContentsMargins(0,0,0,0);
statusBar()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

I am looking for something like this (from Notepad++):
10683

d_stranz
20th October 2014, 20:16
That strip at the top is probably the bottom of the frame around your main window's central widget. (QScrollArea, maybe?) My app, which uses a QTabWidget as the central widget, does not have this extra space on the status bar. The other major difference between your status bar and mine is that you place a pixmap on it, but that shouldn't cause what you see.