You code can be helpfull, but i if i have good understanding of your problem i think that you must use threads for showing progress dialog
You code can be helpfull, but i if i have good understanding of your problem i think that you must use threads for showing progress dialog
a life without programming is like an empty bottle![]()
Sorry zlatko, why do you think that I must use threads? I don't see any relationship between what I want to do and the use of threads... Maybe you mean that I must use threads to update the widgets?Originally Posted by zlatko
Last edited by SkripT; 30th March 2006 at 11:14.
Ok show you available now code maiby problem will be easier![]()
a life without programming is like an empty bottle![]()
That's the code for both widgets of the dialog:
This method is to update the contents of the widget:
Qt Code:
void ImageWindow::updateWindow() { if (fotoValida && taulaValida) return; progres.setMinimumDuration(0); progres.setValue(1); if (!fotoValida) { butoEditorFoto -> setEnabled(foto -> fixaFoto(QImage(pathFoto)/*.scaled(tamIniAreaFoto, Qt::KeepAspectRatio)*/)); fotoValida = true; } progres.setValue(2); if(!taulaValida) { omplirParamsFitxer(); omplirParamsRetallat(); taulaValida = true; } progres.setValue(3); }To copy to clipboard, switch view to plain text mode
That's how I reimplement the showEvent:
Qt Code:
{ if (!event -> spontaneous()) updateWindow(); }To copy to clipboard, switch view to plain text mode
At the beginning "fotoValida" and "taulaValida" are false, so in the first time that the widgets are shown they update their contents. The problem is that this first update is before the dialog window is shown (painted on screen). That's the real problem detailed in my first post.
Last edited by SkripT; 30th March 2006 at 12:23.
This is how I've tried it the last time:
This is the reimplementation of the showEvent method for the dialog that I used to to the test:
Qt Code:
{ if (!event -> spontaneous()) { finestraFoto -> hide(); finestraFotoOriginal -> hide(); show(); repaint(); qApp -> processEvents(); finestraFoto -> show(); finestraFotoOriginal -> show(); } }To copy to clipboard, switch view to plain text mode
"finestraFoto" and "finestraFotoOriginal" are the widgets of class "ImageWindow" that show the progress dialog.
Anybody could explain me why the progress dialogs continue appearing before the dialog windows is drawn???![]()
Could someone suggest me a way to know when the dialog is shown (painted) for the first time? I've tried emiting a signal in the showEvent but it doen't works. What I want is delay the update of the widgets (showing the progress dialog while doing it) that contains the dialog window until it is drawn
Hi again, let's see if this time I have more luckI attach three images showing the steps that I want to follow/obtain in sequence when the dialog window is executed:
1) First step (image 1): show the dialog window with the contents of both image widgets "empty".
2)Second Step (image 2): show the progress dialog while both widgets are updating their contents. It will show two progress dialogs one after the other for each image widget.
3)Third Step (image 3): the update process is finished.
The problem is that it's impossible to begin with the first step: it always starts with the second step, without showing the "empty dialog" on background. I want to know some method to first show the dialog and then update its contents.
Last edited by SkripT; 31st March 2006 at 15:15.
Nobody could suggest me something?![]()
![]()
![]()
![]()
Try adding a single shot timer with 0 timeout in showEvent:Qt Code:
}To copy to clipboard, switch view to plain text mode
SkripT (31st March 2006)
Thanks jacek I had not thought in this particular solution. That's why I need some suggestions from experienced peopleTomorrow I will try it and I will comment the results. What I don't understnad is why emiting a signal in the showEvent (connected to the update method) it doesn't works. The behaviour is simliar at this solution with the timer, no?
Last edited by SkripT; 31st March 2006 at 23:28.
Signals and slots
vs.When a signal is emitted, the slots connected to it are usually executed immediately, just like a normal function call.
QTimer
As a special case, a QTimer with a timeout of 0 will time out as soon as all the events in the window system's event queue have been processed. This can be used to do heavy work while providing a snappy user interface.
Last edited by jpn; 1st April 2006 at 10:21.
SkripT (1st April 2006)
Thanks jpn, I didn't knew that. This post has been very useful.
PD: Finally it works (doing it with the timer)!!!
Last edited by SkripT; 1st April 2006 at 10:37.
Bookmarks