Re: Qftp Put Image to FTP
I also just tried this route. Nothing in the ftp either
Code:
void PGC::shootScreen()
{
*dtStr = dt.toString("ddMMyyyy_hhmmss");
filename = *dtStr + tr("_PGC.") + format;
originalPixmap
= QPixmap();
// clear image for low memory situations // on embedded devices.
updateScreenshotLabel();
image = originalPixmap.toImage();
image.save(&buffer, "PNG"); // writes image into ba in PNG format
if (!originalPixmap.save("test.png")) {
// Saving didn't work
QMessageBox::warning(this,
"Saving error",
"Could not save the file. Check the plugins!");
}
QObject::connect(connection,
SIGNAL(done
(bool)),
this,
SLOT(quit
()));
connection->connectToHost(ftphost);
connection->login(user, password);
//connection->cd("SS");
if (!connection
->put
(ba,
"test.png",
QFtp::Binary)) { // FTP SS didn't work
QMessageBox::warning(this,
"FTP SS Error",
"Could not save the SS to FTP!");
}
file
->open
(QFile::ReadOnly);
if (!connection->put(file, "test.png")) {
// FTP SS didn't work
QMessageBox::warning(this,
"FTP SS Error2",
"Could not save the SS to FTP!");
}
connection->close( );
}
Re: Qftp Put Image to FTP
Is there a way to check the ftp->put command for progress? or file size or mime type?
Re: Qftp Put Image to FTP
Quote:
Originally Posted by
harleyskater
Is there a way to check the ftp->put command for progress? or file size or mime type?
What version of Qt are you running? In 4.6.3, there is a dataTransferProgress() function in QFtp.
As for the QFtp::put() function, your if statement is going to return immediately if the command was scheduled. You need to check the QFtp::done() and QFtp::error() functions for the status of the transfer.
Re: Qftp Put Image to FTP
I went through the documentation and I set some breakpoints on the ftp.error and ftp.currentcommand so I could let some time pass between hits.
They all return the same thing
error = 0 //no error
current = 3 // QFtp::ConnectToHost - connectToHost() is being executed.
Code:
void PGC::shootScreen()
{
*dtStr = dt.toString("ddMMyyyy_hhmmss");
filename = *dtStr + tr("_PGC.") + format;
originalPixmap
= QPixmap();
// clear image for low memory situations // on embedded devices.
updateScreenshotLabel();
image = originalPixmap.toImage();
image.save(&buffer, "PNG"); // writes image into ba in PNG format
if (!originalPixmap.save("test.png")) {
// Saving didn't work
QMessageBox::warning(this,
"Saving error",
"Could not save the file. Check the plugins!");
}
QObject::connect(connection,
SIGNAL(done
(bool)),
this,
SLOT(quit
()));
connection->connectToHost(ftphost);
connection->login(user, password);
//connection->cd("SS");
if (!connection
->put
(ba,
"test.png",
QFtp::Binary)) { // FTP SS didn't work
QMessageBox::warning(this,
"FTP SS Error",
"Could not save the SS to FTP!");
}
/*QFile *file = new QFile("test.png", this);
if (!file->open(QFile::ReadOnly))
{
// FTP SS didn't work
QMessageBox::warning(this, "FTP SS Error3", "Could not open the SS !");
file->close();
delete file;
}
if (!connection->put(file, "test.png")) {
// FTP SS didn't work
QMessageBox::warning(this, "FTP SS Error2", "Could not save the SS to FTP!");
} */
QVariant ftperror
= connection
->error
();
QVariant ftpcurrent
= connection
->currentCommand
();
ftperror = connection->error();
ftpcurrent = connection->currentCommand();
ftperror = connection->error();
ftpcurrent = connection->currentCommand();
ftperror = connection->error();
ftpcurrent = connection->currentCommand();
ftperror = connection->error();
ftpcurrent = connection->currentCommand();
connection->close( );
}
Re: Qftp Put Image to FTP
The QFtp class works asynchronously to transfer data. So, calling the connecToHost, put, error, currentCommand, and close functions sequentially will never actually execute any of the commands. What you need to do is write a class so that you can use signals and slots. Catching the signals after you start transferring is the key. The example listed in the QFtp detailed description gives some clarification to your issue.
Hope this helps.
Re: Qftp Put Image to FTP
I also noticed, because I tried to show a friend what I was working on by passing him the build exe that anywhere I put "ftp = new QFtp();" it crashes the app but when I execute it through the IDE it doesn't crash. I have the project setup for ftp.
Re: Qftp Put Image to FTP
Just put the command connection->close( ); to a slot catching the done() signal. You're closing the connection before the actions are executed.
Re: Qftp Put Image to FTP
Thank you Vit! I wasn't sure how that connection->close( ); would execute and when! but you are right. works great now! except for the problem where it won't execute outside of the IDE. I debugged in release mode and it runs from the IDE and it works, uploads to the FTP, but if I execute it outside of the IDE it crashes when it hits the FTP code.
Re: Qftp Put Image to FTP
I found this page for documentation,
http://doc.trolltech.com/4.3/deployment-windows.html
The only thing I saw for Visual Studios that I wasn't doing was copying the plugins DIR to my release folder.
I copied the entire Plugins dir to my release dir and I have the same problem
Re: Qftp Put Image to FTP
still no advice on this? because im still stuck.
Re: Qftp Put Image to FTP
Well, Qt Creator executes the exe too, so if it crashes outside of Qt Creator, then your environment is different (eg. path)
1 Attachment(s)
Re: Qftp Put Image to FTP
Okay I went back and set my Output Directory so my exe goes into the same folder as the rest of my release
now when I compile, my exe goes to my Projects /Release Folder and not my Solutions.
My program is still crashing outside of my IDE, and I believe you are right that its my envirornment outside of my IDE that is causing the crash but I am not sure what part of my environment.
It is crashing at this line. I have in my project the need to include a lot of dll's but I am thinking it would be the Network DLL that would be causing the problem since it is crashing at this line: QFtp *connectionftp = new QFtp(this);
I am attaching a screenshot of my release folder
Re: Qftp Put Image to FTP
project stilllll isn't working did anyone take a look at that screenshot? is it possible its the library and not the dll?
Re: Qftp Put Image to FTP
Where do you output that error?
Re: Qftp Put Image to FTP
that error is actually just a message box I put before and after the line of code that is failing to track down where the app is failing, kinda like a die statement.
QFtp *connectionftp = new QFtp(this);
Re: Qftp Put Image to FTP
So you took a picture of a message box you created yourself and are asking us why that message box appears?
Re: Qftp Put Image to FTP
no, I am wondering why my program crashes when it reaches this line of code
QFtp *connectionftp = new QFtp(this);
I took the screenshot only to show that I have all the dll's located in the builds dir.
It executes great when ran within MSVS2008 but the exe outside of the IDE crashes on that line. I took the screenshot to show I am including what I need to.
Re: Qftp Put Image to FTP
Well, MSVS2008 doesn't run your program from the "Release" dir, it's runs it from your projects home directory (which is typically where your source code is) so it's not using the DLLs in your release directory when its running from within the IDE.
So, delete all the files in the release directory. All of them. Then do a full rebuild and see if it works then, from a VS2008 command prompt. If it does, there's something wrong with one of the DLLs which was there.
Re: Qftp Put Image to FTP
Any body please look into my thread "Slow FTP Program using QFtp" Its very Urgent and Please help me.
Thanks in advance