Results 1 to 5 of 5

Thread: Modeless dialog disappearing

  1. #1
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Exclamation Modeless dialog disappearing

    Hi everyone!

    Well, my problem is simple:
    I want to show a dialog that is containing a ProgressBar, that notices about the progress of a parallel long process, while the user stays working normally on the main window. I would like this dialog in "Find & Replace" style of word-processors.
    The manual talks about a :
    Qt Code:
    1. dialog->setModal(TRUE);
    2. dialog->show();
    To copy to clipboard, switch view to plain text mode 
    but I saw many examples that do not use setModal function, just show().
    So I used just show() and the result is that the dialog appears and disappears quickly!
    Could it be because of the missing of this piece of code I saw somewhere? :
    Qt Code:
    1. dialog->show();
    2. dialog->raise();
    3. dialog->activateWindow();
    To copy to clipboard, switch view to plain text mode 
    or maybe not. Why this "magician trick" dialog?

    Thank you a big lot to who will help!

    PS: to apply and test changes I have to wait for a compilation of about three hours long, but I'm starting to have no time left...so please give me straight answers... thanks a lot!
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Modeless dialog disappearing

    Hard to say.
    What does the dialog actually do? Maybe you have an error somewhere else in your code, for example in the communication between the dialog and the parallel process.

    Some code might clear things

  3. #3
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Modeless dialog disappearing

    I thought it too, but the code doesn't present any sort of cleaning out of control...
    Additionally I noticed that exec() instead of show() , shows the dialog perfectly but it doesn't permit interaction with the main window behind the dialog, because it is modal.
    So maybe it is a problem dued to show() ?
    What does the dialog actually do?
    the dialog, when pushed its button, comes up for a fifth of second and then disappears.
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Modeless dialog disappearing

    Quote Originally Posted by Raccoon29 View Post
    the dialog, when pushed its button, comes up for a fifth of second and then disappears.
    Just to ensure, you are allocating the dialog on the heap (like the code snippet in the first post suggests), right? Allocating the dialog accidentally on the stack usually leads to similar problems than you have described.

    heap vs. stack
    Qt Code:
    1. {
    2. QDialog* dialog = new QDialog(this);
    3. dialog->show();
    4. } // dialog remains alive
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. {
    2. QDialog dialog(this);
    3. dialog.show();
    4. } // dialog goes out of scope
    To copy to clipboard, switch view to plain text mode 
    On the other hand, QDialog::exec() makes it work because it blocks:
    Qt Code:
    1. {
    2. QDialog dialog(this);
    3. dialog.exec(); // starts an event loop and blocks as long as the dialog is visible
    4. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    Raccoon29 (15th September 2007)

  6. #5
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Modeless dialog disappearing

    uhmmm, yes. It must be so
    Oh God, you all are incredible...
    I'm going to test and report soon, thank you!
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

Similar Threads

  1. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  2. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48
  3. modeless dialog closed signal?
    By gfunk in forum Qt Programming
    Replies: 2
    Last Post: 5th January 2007, 00:40
  4. modeless dialog
    By mhoover in forum Newbie
    Replies: 2
    Last Post: 23rd March 2006, 22:56
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

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.