Re: Problems with a dialog
From QProgressDialog docs:
Quote:
The dialog automatically resets and hides itself at the end of the operation. Use
setAutoReset() and
setAutoClose() to change this behavior.
Re: Problems with a dialog
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?
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?
Re: Problems with a dialog
Does your program enter some kind of a loop after it shows that progress dialog?
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.
Re: Problems with a dialog
Could you show some code?
1 Attachment(s)
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:
Code:
FinestraFoto
::FinestraFoto(QWidget *parent
){
(.......)
progres.setRange(0, 3);
progres.setCancelButtonText(0);
progres.setMinimumDuration(0); // I want to show it always
(.........)
}
That's how I declare ithe progress dialog.
Code:
void FinestraFoto::actualitzarFinestra(bool actualitzarFoto, bool actualitzarParamsFitxer,
bool actualitzarParamsRetallat)
{
if (!actualitzarFoto && !actualitzarParamsFitxer && !actualitzarParamsRetallat) return;
progres.setValue(1);
if (actualitzarFoto)
{
tamIniAreaFoto = fotoArea -> maximumViewportSize();
butoEditorFoto
-> setEnabled
(foto
-> fixaFoto
(QImage(pathFoto
).
scaled(tamIniAreaFoto, Qt
::KeepAspectRatio)));
}
progres.setValue(2);
if(actualitzarParamsFitxer)
omplirParamsFitxer();
if(actualitzarParamsRetallat)
omplirParamsRetallat();
progres.setValue(3);
}
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.
Re: Problems with a dialog
Code:
progres.setValue(2);
if(actualitzarParamsFitxer)
omplirParamsFitxer();
if(actualitzarParamsRetallat)
omplirParamsRetallat();
progres.setValue(3);
Do you allow Qt to process events between subsequent calls to setValue()?
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:
Code:
QProgressDialog progress
("Copying files...",
"Abort Copy",
0, numFiles,
this);
for (int i = 0; i < numFiles; i++) {
progress.setValue(i);
qApp->processEvents();
if (progress.wasCanceled())
break;
//... copy one file
}
progress.setValue(numFiles);
Re: Problems with a dialog
Notice the statement on line 4..
Do you call QApplication::processEvents() anywhere?
Re: Problems with a dialog
Quote:
Originally Posted by jpn
Notice the statement on line 4..
Do you call QApplication::processEvents() 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 :eek: :confused: :(
Re: Problems with a dialog
Try calling progres.raise() before setValue().
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 :eek: :confused: :(
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.
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? :confused:
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?
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)....