Results 1 to 17 of 17

Thread: Problems with a dialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with a dialog

    Does your program enter some kind of a loop after it shows that progress dialog?

  2. #2
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with a dialog

    Quote Originally Posted by jacek
    Does your program enter some kind of a loop after it shows that progress dialog?

    I have to add that the progress dialog is used not for the dialog itself but for a child widget of this dialog, but I don't think that this could cause the problem. The progress dialog is created in the creation of the child widget, where I set its minimum duration and its range. Then is shown by calling QProgressDialog::setValue in the methods where I use it. I have to do it in this way because I need to subclass this child widget and each class has its own text for the QProgressDialog but its range and minimum duration is equal. Also the progress dialog is used in the main class not in these subclasses.
    Last edited by SkripT; 28th March 2006 at 16:12.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with a dialog

    Could you show some code?

  4. #4
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with a dialog

    Quote Originally Posted by jacek
    Could you show some code?
    Well it's a little long but I show how I use the progress dialog:

    Qt Code:
    1. FinestraFoto::FinestraFoto(QWidget *parent)
    2. : QWidget(parent)
    3. {
    4. (.......)
    5. progres.setRange(0, 3);
    6. progres.setCancelButtonText(0);
    7. progres.setMinimumDuration(0); // I want to show it always
    8. (.........)
    9. }
    To copy to clipboard, switch view to plain text mode 

    That's how I declare ithe progress dialog.

    Qt Code:
    1. void FinestraFoto::actualitzarFinestra(bool actualitzarFoto, bool actualitzarParamsFitxer,
    2. bool actualitzarParamsRetallat)
    3. {
    4. if (!actualitzarFoto && !actualitzarParamsFitxer && !actualitzarParamsRetallat) return;
    5.  
    6. progres.setValue(1);
    7.  
    8. if (actualitzarFoto)
    9. {
    10. tamIniAreaFoto = fotoArea -> maximumViewportSize();
    11. butoEditorFoto -> setEnabled(foto -> fixaFoto(QImage(pathFoto).scaled(tamIniAreaFoto, Qt::KeepAspectRatio)));
    12. }
    13.  
    14. progres.setValue(2);
    15.  
    16. if(actualitzarParamsFitxer)
    17. omplirParamsFitxer();
    18. if(actualitzarParamsRetallat)
    19. omplirParamsRetallat();
    20.  
    21. progres.setValue(3);
    22. }
    To copy to clipboard, switch view to plain text mode 

    And that's how I use it everytime "actualitzarFinestra" is called.

    then I have 2 subclasses of FinestraFoto where I set the text of the progress dialog for each of them. These subclasses use "FinestraFoto::actualitzarFinestra" method and these widgets are part of the modal dialog. I attach an example of the dialog window, where you can see that these two subclasses correspond with each "image" window. And the progress bars are shown when each image is loaded and each table is filled.
    Attached Images Attached Images
    Last edited by SkripT; 28th March 2006 at 16:38.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with a dialog

    Qt Code:
    1. progres.setValue(2);
    2.  
    3. if(actualitzarParamsFitxer)
    4. omplirParamsFitxer();
    5. if(actualitzarParamsRetallat)
    6. omplirParamsRetallat();
    7.  
    8. progres.setValue(3);
    To copy to clipboard, switch view to plain text mode 
    Do you allow Qt to process events between subsequent calls to setValue()?

  6. #6
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with a dialog

    Quote Originally Posted by jacek
    Do you allow Qt to process events between subsequent calls to setValue()?
    I don't understand what you mean jacek. The documentation explains that the progress dialog can be used this way:
    Qt Code:
    1. QProgressDialog progress("Copying files...", "Abort Copy", 0, numFiles, this);
    2. for (int i = 0; i < numFiles; i++) {
    3. progress.setValue(i);
    4. qApp->processEvents();
    5.  
    6. if (progress.wasCanceled())
    7. break;
    8. //... copy one file
    9. }
    10. progress.setValue(numFiles);
    To copy to clipboard, switch view to plain text mode 

  7. #7
    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: Problems with a dialog

    Notice the statement on line 4..
    Do you call QApplication:rocessEvents() anywhere?

  8. #8
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with a dialog

    Quote Originally Posted by jpn
    Notice the statement on line 4..
    Do you call QApplication:rocessEvents() anywhere?
    You are right jpn, but I've tried it calling to processEvents after setting each value and the progress dialog is not shown (appears for only one second and then is hidden suddenly) Moreover I think that the processEvents statement is to caught when the user press the cancel button but I have disabled it
    Last edited by SkripT; 28th March 2006 at 17:52.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with a dialog

    Try calling progres.raise() before setValue().

  10. #10
    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: Problems with a dialog

    Quote Originally Posted by SkripT
    Moreover I think that the processEvents statement is to caught when the user press the cancel button but I have disabled it
    Actually, if you want your application to response to any user interaction, you will have to let it to process it's events once in a while. Besides of moving the windows/dialogs and so on, this user interaction includes also redrawing e.g. when switching between different applications.

  11. #11
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with a dialog

    Thanks jpn and jacek. Finally I've found the problem. Before, I was creating the progress dialog with no parent (0). But if I create the progress dialog everytime on "actualitzarFinestra" and set its parent to "this", it's shown. Really strange, don't you think?
    Last edited by SkripT; 29th March 2006 at 10:01.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with a dialog

    Quote Originally Posted by SkripT
    I was creating the progress dialog with no parent (0). But if I create the progress dialog everytime on "actualitzarFinestra" and set its parent to "this", it's shown.
    Do you invoke the show() method?

  13. #13
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with a dialog

    Quote Originally Posted by jacek
    Do you invoke the show() method?
    Good suggestion jacek, but I've tried it calling to show but it neither appears (it's hidden after 1 sec)....
    Last edited by SkripT; 29th March 2006 at 13:21.

Similar Threads

  1. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  2. [Eclipse/Integration] Project Settings dialog problems
    By BrainB0ne in forum Installation and Deployment
    Replies: 0
    Last Post: 23rd January 2008, 15:52
  3. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  4. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48
  5. Problems updating a dialog
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 1st April 2006, 10:17

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
  •  
Qt is a trademark of The Qt Company.