PDA

View Full Version : QLineEdit insight the QStatusBar problem



bazzdle
8th November 2012, 10:45
Hello. I have subclassed QMainWindow and in the Status bar I put a LineEdit.


QLineEdit *lineEdit = new QLineEdit;
statusBar()->addWidget(lineEdit);

The problem I have is that when I start the app the Status bar appears little bigger than it's normal size and after a second it becomes to the normal size. So I checked the sizeHint() of these two widgets:


QLineEdit *lineEdit = new QLineEdit;
qDebug() << statusBar()->minimumSizeHint(); // Status bar before adding the LineEdit's Height(22)

qDebug() << lineEdit->minimumSizeHint(); // LineEdit's Height (27)
statusBar()->addWidget(lineEdit);

qDebug() << statusBar()->minimumSizeHint(); // Status bar after adding the LineEdit (32)

I saw that the LineEdit's height is bigger and the Status bar try to adjust the size. So I tried to set
lineEdit->setFixedHeight(19) and
statusBar->setFixedHeight(32) but it is still the same;

I tried with the setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preffered) as well but nothing changed.

I use Ubuntu 12.04 and the program was run with diffrent styles (Plastique, CleenLooks) but the result is the same.
It's happening only when I have QLineEdit insight.

One more thing:
It happens mainly when I quit the app maximized or i switch from minimize to maximize. These are my Settings:


void MainWindow::readSettings()
{

QSettings settings("MySettings", "app");
move(settings.value("position", QPoint(200, 200)).toPoint());

QByteArray windowGeometry = settings.value("geometry").toByteArray();
restoreGeometry(windowGeometry);

QByteArray windowState = settings.value("state").toByteArray();
restoreState(windowState);

}

//================================================== ========================================

void MainWindow::writeSettings()
{


QSettings settings("MySettings", "app");
settings.setValue("position", pos());
settings.setValue("geometry", saveGeometry());
settings.setValue("state", saveState());
}

Can someone help me?