Results 1 to 9 of 9

Thread: QMessageBox misbehaves after QFileDialog call

  1. #1
    Join Date
    May 2009
    Posts
    15
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry QMessageBox misbehaves after QFileDialog call

    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.

    Qt Code:
    1. void Terminal::on_actionOpen_triggered()
    2. {
    3. QFileDialog fDialog;
    4. QString fileName = fDialog.getOpenFileName(this, tr("Open File"), "app/", tr("All Files (*)"), 0, 0);
    5. if (fileName == "") {
    6. QMessageBox msgBox(QMessageBox::Information, QApplication::applicationName(), tr("Open operation canceled."), QMessageBox::Close, this, 0);
    7. msgBox.exec();
    8. return;
    9. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by MikeG; 29th May 2009 at 15:39.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMessageBox misbehaves after QFileDialog call

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    MikeG (19th June 2009)

  4. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMessageBox misbehaves after QFileDialog call

    and QMessageBox also has static function which does what you need I think: QMessageBox::information().
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. The following user says thank you to faldzip for this useful post:

    MikeG (19th June 2009)

  6. #4
    Join Date
    May 2009
    Posts
    15
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMessageBox misbehaves after QFileDialog call

    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.
    Last edited by MikeG; 1st June 2009 at 11:54.

  7. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMessageBox misbehaves after QFileDialog call

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #6
    Join Date
    May 2009
    Posts
    15
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMessageBox misbehaves after QFileDialog call

    Implemented with both static methods. I tested the archive to make sure it compiled before uploading.
    Attached Files Attached Files

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMessageBox misbehaves after QFileDialog call

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #8
    Join Date
    May 2009
    Posts
    15
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMessageBox misbehaves after QFileDialog call

    Which desktop environment / Linux distro are you using? Ubuntu uses Gnome. Thanks for trying.

  11. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMessageBox misbehaves after QFileDialog call

    I'm using KDE4 with kwin4 as window manager under Mandriva.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    MikeG (19th June 2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.