How To "Loading"......
-
The programme need popu a dialog when user click a button,but the dialog need to do some work that maybe need to cost 3-5 sec when it launch....
As you know,it's a bad idea that the user must cost 3-5 sec to wait the dialog's show.I find a pix.gif to cover that the dialog need to cost 3-5 sec to launch...
This is the Load.gif....
And the code looks like this
void APT::allowRecoderMsg() //the slot connect the single of QPushButton's { load_Movie->setFileName(tr(":/source/pix/Load.gif")); load_Label->setMovie(load_Movie); load_Move->start(); load_Label->show(); if(recorde_Dialog != null) recorde_Dialog = new RecordeDialog(this); //thie line will cost 3-5 sec load_Label->hide(); recorde_Dialog->exec(); }
On my plan,I play a gif(on the QLabel) first, and executive the constructor of the class RecordeDialog(it will cost 3-5 sec),when the constructor of class RecordeDialog had executived,I hide the gif(label->hide()) and show the dialog(dialog->exec());
But in fact ,when i executive the construct of class RecordeDialog,the gif will be stop..How to keep the GIF on running when dialog is executiving? -
The programme need popu a dialog when user click a button,but the dialog need to do some work that maybe need to cost 3-5 sec when it launch....
As you know,it's a bad idea that the user must cost 3-5 sec to wait the dialog's show.I find a pix.gif to cover that the dialog need to cost 3-5 sec to launch...
This is the Load.gif....
And the code looks like this
void APT::allowRecoderMsg() //the slot connect the single of QPushButton's { load_Movie->setFileName(tr(":/source/pix/Load.gif")); load_Label->setMovie(load_Movie); load_Move->start(); load_Label->show(); if(recorde_Dialog != null) recorde_Dialog = new RecordeDialog(this); //thie line will cost 3-5 sec load_Label->hide(); recorde_Dialog->exec(); }
On my plan,I play a gif(on the QLabel) first, and executive the constructor of the class RecordeDialog(it will cost 3-5 sec),when the constructor of class RecordeDialog had executived,I hide the gif(label->hide()) and show the dialog(dialog->exec());
But in fact ,when i executive the construct of class RecordeDialog,the gif will be stop..How to keep the GIF on running when dialog is executiving?@qazaq408
why does the dialog take such long time in it's constructor?
You need to move the heavy processing into a separate thread and open the dialog once the data is ready.Your problem is that you put the heavy load on the UI thread (the default thread) which prevents further painting.
-
@qazaq408
why does the dialog take such long time in it's constructor?
You need to move the heavy processing into a separate thread and open the dialog once the data is ready.Your problem is that you put the heavy load on the UI thread (the default thread) which prevents further painting.
@raven-worx said in How To "Loading"......:
@qazaq408
why does the dialog take such long time in it's constructor?
You need to move the heavy processing into a separate thread and open the dialog once the data is ready.Your problem is that you put the heavy load on the UI thread (the default thread) which prevents further painting.
1 The dialog need to read some pix that may be on the disk,and the pix used in medic so that it's always 10Mb or bigger...
2 Wether the QLabel(play GIF) or QDialog,thet are all children of QWidget and only run on the main thread
-
@raven-worx said in How To "Loading"......:
@qazaq408
why does the dialog take such long time in it's constructor?
You need to move the heavy processing into a separate thread and open the dialog once the data is ready.Your problem is that you put the heavy load on the UI thread (the default thread) which prevents further painting.
1 The dialog need to read some pix that may be on the disk,and the pix used in medic so that it's always 10Mb or bigger...
2 Wether the QLabel(play GIF) or QDialog,thet are all children of QWidget and only run on the main thread
@qazaq408 said in How To "Loading"......:
Wether the QLabel(play GIF) or QDialog,thet are all children of QWidget and only run on the main thread
i know. i said you should move just the processing to another thread.
This means the loading of the image into memory. You cannot use QPixmap outside the ui thread. So you will need to use QImage.Also you are advised to think about some smart handling of such big image files.
How exactly are you displaying/painting the image at the end?I think it's a good idea to paint the image by directly accessing it's bytedata and/or only painting and accessing the visible parts of the image.
-
@qazaq408 said in How To "Loading"......:
Wether the QLabel(play GIF) or QDialog,thet are all children of QWidget and only run on the main thread
i know. i said you should move just the processing to another thread.
This means the loading of the image into memory. You cannot use QPixmap outside the ui thread. So you will need to use QImage.Also you are advised to think about some smart handling of such big image files.
How exactly are you displaying/painting the image at the end?I think it's a good idea to paint the image by directly accessing it's bytedata and/or only painting and accessing the visible parts of the image.
@raven-worx
Thank you.
In fact,I had got the question by load pix in child Thread.But I think there some widgets, that's maybe
need to cost a little long time for construction.So,I'm very curious to konw how to use the "Loading.gif" when the widget is on the construction.,you konw,many software has the funtion look like this, and there software usually play a gif when a widget/dialog/others is launching. -
@raven-worx
Thank you.
In fact,I had got the question by load pix in child Thread.But I think there some widgets, that's maybe
need to cost a little long time for construction.So,I'm very curious to konw how to use the "Loading.gif" when the widget is on the construction.,you konw,many software has the funtion look like this, and there software usually play a gif when a widget/dialog/others is launching.@qazaq408
there's also QPixmapCache, haven't used it yet, but that way you should be able to push the delay in the startup of your application or do it scattered for each Image, to prevent/reduce freezes