wait copy picture then show it
Hi everybody
QT 4.1.3 WINXP MINGW
I have a functionm that copy a picture from a server local and show it.
My function work, but sometimes the copy process is not fast and i cant see the picture.
I am searching a solution for my function, that i wait until the picture is complete copied local, and then show it.
Have somebody a idea? :crying:
Code:
void MainWindow::showPicure()
{
ui.label->clear();
QString src
= (ui.
listView->currentItem
() )->text
( 4 );
if(file.isReadable() == true)
{
Q3UrlOperator *op = new Q3UrlOperator();
QString temp_picture
= "c:/temp/temp_album.jpg";
op->copy(src, temp_picture, false, false);
ui.
label->setPixmap
(QPixmap(temp_picture
));
ui.picture_lb->setText("");
}
else
{
ui.picture_lb->setText("No Picture");
ui.label->clear();
}
}
Re: wait copy picture then show it
Use signals and slots. The url operator will tell you when it will have finished the operation. You can connect a slot to it and continue.
Re: wait copy picture then show it
Hi wysota,
Thanks for your answer..
How could i make that? Have you a example for me? :crying:
Re: wait copy picture then show it
Split your code. One part of it should contain operations to be performed before the download is finished. The other (it should be a slot) should contain operations to be started after the download will have finished. Then at the end of the first part you can use QUrlOperator and connect the second part to its finished() signal. When the download is finished, the slot will be called and your code will continue its job.
Re: wait copy picture then show it
Hi wysota, i think i have understand now,
but my function test will never called why?
Code:
void MainWindow::showPicure()
{
ui.label->clear();
QString src
= (ui.
listView->currentItem
() )->text
( 4 );
if(file.isReadable() == true)
{
Q3UrlOperator *op = new Q3UrlOperator();
QString temp_picture
= "c:/temp/temp_album.jpg";
op->copy(src, temp_picture, false, false);
connect(op, SIGNAL(finished()), this, SLOT(test()));
ui.picture_lb->setText("");
}
else
{
ui.picture_lb->setText("No Picture");
ui.label->clear();
}
}
void MainWindow::test()
{
ui.
label->setPixmap
(QPixmap("c:/temp/temp_album.jpg"));
}
Re: wait copy picture then show it
Quote:
Originally Posted by
raphaelf
but my function test will never called why?
The signature of the signals is: finished(Q3NetworkOperation*) so it should be something like:
Code:
connect(op, SIGNAL(finished(Q3NetworkOperation*)), this, SLOT(test()));
Re: wait copy picture then show it
Thanks JPN and Wysota it works:p :p