Results 1 to 7 of 7

Thread: wait copy picture then show it

  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default 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?
    Qt Code:
    1. void MainWindow::showPicure()
    2. {
    3. ui.label->clear();
    4. QString src = (ui.listView->currentItem() )->text( 4 );
    5. QMessageBox::information(this, "src", src);
    6. QFileInfo file(src);
    7. if(file.isReadable() == true)
    8. {
    9.  
    10. Q3UrlOperator *op = new Q3UrlOperator();
    11. QString temp_picture = "c:/temp/temp_album.jpg";
    12. op->copy(src, temp_picture, false, false);
    13. QMessageBox::information(this, "wait", "wait");
    14. ui.label->setPixmap(QPixmap(temp_picture));
    15. ui.picture_lb->setText("");
    16. }
    17. else
    18. {
    19. ui.picture_lb->setText("No Picture");
    20. ui.label->clear();
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

  3. The following user says thank you to wysota for this useful post:

    raphaelf (5th November 2006)

  4. #3
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: wait copy picture then show it

    Hi wysota,

    Thanks for your answer..

    How could i make that? Have you a example for me?
    Think DigitalGasoline

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

  6. #5
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: wait copy picture then show it

    Hi wysota, i think i have understand now,

    but my function test will never called why?

    Qt Code:
    1. void MainWindow::showPicure()
    2. {
    3. ui.label->clear();
    4. QString src = (ui.listView->currentItem() )->text( 4 );
    5. QFileInfo file(src);
    6. if(file.isReadable() == true)
    7. {
    8.  
    9. Q3UrlOperator *op = new Q3UrlOperator();
    10. QString temp_picture = "c:/temp/temp_album.jpg";
    11. op->copy(src, temp_picture, false, false);
    12. connect(op, SIGNAL(finished()), this, SLOT(test()));
    13. ui.picture_lb->setText("");
    14. }
    15. else
    16. {
    17. ui.picture_lb->setText("No Picture");
    18. ui.label->clear();
    19. }
    20. }
    21. void MainWindow::test()
    22. {
    23. ui.label->setPixmap(QPixmap("c:/temp/temp_album.jpg"));
    24.  
    25. }
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  7. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: wait copy picture then show it

    Quote Originally Posted by raphaelf View Post
    but my function test will never called why?
    The signature of the signals is: finished(Q3NetworkOperation*) so it should be something like:
    Qt Code:
    1. connect(op, SIGNAL(finished(Q3NetworkOperation*)), this, SLOT(test()));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  8. The following user says thank you to jpn for this useful post:

    raphaelf (5th November 2006)

  9. #7
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: wait copy picture then show it

    Thanks JPN and Wysota it works
    Think DigitalGasoline

Similar Threads

  1. Replies: 1
    Last Post: 24th June 2006, 12:10

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.