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
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Problems with a dialog

    Hi all, I've got a widget that opens a dialog. This dialog shows a QProgressDialog in some moments when the user wants to do some actions. I've noticed a problem with this dialog: if i don't exec the dialog, the progressdialog is shown correctly but if I exec the dialog from the widget, the progressbar is not shown like if it's hidden by the dialog. Well, exactly the progressdialog is shown for a seconds (1 or 2) and then is hidden forced. Anybody knows why or where's the mistake?

    Thanks.

  2. #2
    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

    From QProgressDialog docs:
    The dialog automatically resets and hides itself at the end of the operation. Use setAutoReset() and setAutoClose() to change this behavior.

  3. #3
    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
    Thanks jpn, but that's not the problem. I also know it. As I said is like if the progressdialog is hidden because the dialog is forced at the top of the widget's stack. The cause could probably be because it's modal. Is it true?
    Last edited by SkripT; 27th March 2006 at 18:49.

  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

    Hi again, I've updated to Qt4.1.1 but the problem with the progress dialog still presists. It's very strange because the progress dialog attempts to appear, as I commented previously it appears for 1 second but it disappears suddenly (not because it has finished) like if it's obscured for its parent dialog. I've tried to call raise of the progress dialog but it doesn't work. Anybody could tell me why or where's the mistake? Could the cause be that dialog that opens the progress dialog is executed?
    Last edited by SkripT; 28th March 2006 at 15:04.

  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

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

  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
    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.

  7. #7
    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?

  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 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.

  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

    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()?

  10. #10
    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 

  11. #11
    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?

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.