Results 1 to 20 of 20

Thread: Qftp Put Image to FTP

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jun 2010
    Posts
    41
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qftp Put Image to FTP

    I also just tried this route. Nothing in the ftp either

    Qt Code:
    1. void PGC::shootScreen()
    2. {
    3.  
    4. QDateTime dt = QDateTime::currentDateTime();
    5.  
    6. QString *dtStr = new QString();
    7. *dtStr = dt.toString("ddMMyyyy_hhmmss");
    8.  
    9. QString format = "png";
    10. QString filename = "";
    11.  
    12. filename = *dtStr + tr("_PGC.") + format;
    13.  
    14.  
    15. originalPixmap = QPixmap(); // clear image for low memory situations
    16. // on embedded devices.
    17. originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
    18. updateScreenshotLabel();
    19.  
    20. QImage image;
    21. image = originalPixmap.toImage();
    22. QBuffer buffer(&ba);
    23. buffer.open(QIODevice::WriteOnly);
    24. image.save(&buffer, "PNG"); // writes image into ba in PNG format
    25.  
    26.  
    27.  
    28. if (!originalPixmap.save("test.png")) {
    29. // Saving didn't work
    30. QMessageBox::warning(this, "Saving error", "Could not save the file. Check the plugins!");
    31. }
    32.  
    33. QFtp* connection = new QFtp();
    34. QObject::connect(connection, SIGNAL(done(bool)), this, SLOT(quit()));
    35. connection->connectToHost(ftphost);
    36. connection->login(user, password);
    37. //connection->cd("SS");
    38.  
    39. if (!connection->put(ba, "test.png", QFtp::Binary)) {
    40. // FTP SS didn't work
    41. QMessageBox::warning(this, "FTP SS Error", "Could not save the SS to FTP!");
    42. }
    43.  
    44. QFile *file = new QFile("test.png", this);
    45. file->open(QFile::ReadOnly);
    46.  
    47. if (!connection->put(file, "test.png")) {
    48. // FTP SS didn't work
    49. QMessageBox::warning(this, "FTP SS Error2", "Could not save the SS to FTP!");
    50. }
    51.  
    52. connection->close( );
    53.  
    54. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by harleyskater; 28th June 2010 at 08:18.

Similar Threads

  1. QFtp and dataTransferProgress
    By racinglocura07 in forum Qt Programming
    Replies: 2
    Last Post: 24th June 2010, 18:14
  2. Synchronous QFtp?
    By aarpon in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 09:28
  3. QFtp over QHttp
    By parusri in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2009, 19:16
  4. Synchronizing QFtp
    By arun_vj in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2008, 12:31
  5. Replies: 0
    Last Post: 23rd September 2007, 11:54

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.