PDA

View Full Version : QMessageBox misbehaves after QFileDialog call



MikeG
29th May 2009, 15:32
OS: Ubuntu 8.10 w/ partial upgrade to 9.04
Qt Version: 4.5.1 Qt Creator: 1.1.0

When calling fDialog.getOpenFileName, QMessageBox no longer obeys where you tell it to move to. For instance, being a parent of the Terminal window, it will not center. Calling msgBox.move(x,y) does not move the QMessageBox. It always starts in the same awkward place. If fDialog.getOpenFileName is not called, the QMessageBox moves whereever is needed.


void Terminal::on_actionOpen_triggered()
{
QFileDialog fDialog;
QString fileName = fDialog.getOpenFileName(this, tr("Open File"), "app/", tr("All Files (*)"), 0, 0);
if (fileName == "") {
QMessageBox msgBox(QMessageBox::Information, QApplication::applicationName(), tr("Open operation canceled."), QMessageBox::Close, this, 0);
msgBox.exec();
return;
}

wysota
30th May 2009, 13:31
QFileDialog::getOpenFileName is a static method. Maybe a non-static use of it causes some internal problems. Use it as a static method and see if the problem persists.

faldzip
30th May 2009, 15:31
and QMessageBox also has static function which does what you need I think: QMessageBox::information().

MikeG
1st June 2009, 11:48
I initially had used the static method of getOpenFileName and had the same result. Tried both static methods suggested and the same problem persists. Even though I've pasted an example within my class, I've also tried it virtually by itself in a new project and still get the same thing. The only thing that occurred to me is that it must be some form of Qt enforcing some weird Gnome GUI policy. If the open file dialog is moved, the msgBox always makes sure that it doesn't appear within the same space that the open file dialog was in.

wysota
1st June 2009, 18:25
Please provide a minimal compilable example reproducing the problem.

MikeG
1st June 2009, 19:18
Implemented with both static methods.:D I tested the archive to make sure it compiled before uploading.

wysota
1st June 2009, 19:43
I can't reproduce the bug. I'm using Qt 4.5.0 on Linux/i386 and the message box is centred over the main window instance.

MikeG
1st June 2009, 21:15
Which desktop environment / Linux distro are you using? Ubuntu uses Gnome. Thanks for trying.:D

wysota
2nd June 2009, 10:17
I'm using KDE4 with kwin4 as window manager under Mandriva.