QFSFileEngine::open: No file name specified
I all , how do I select a file from a directory? Both the file and directory is visible
to me when I run the code. When I selct a file and double click it I get the error
message and the following info:
Here is the code snippet:
- void FtpClientDlg::selectFile() {
- QString fileName;
- if (files.isEmpty())
- return;
- Q_ASSERT(file != NULL);
- ui->statusLabel->setText("open error "+file->fileName());
- return;
- }
- ui->statusLabel->setText("Upload start");
- ftp->put(file,fileName);
- ui->statusLabel->setText("Upload end");
- }
7 replies
- void FtpClientDlg::selectFile() {
- QString fileName;
- // QString files = QFileDialog::getOpenFileName(this, tr("Select File"), "/");
- // if (files.isEmpty())
- // return;
- // Q_ASSERT(file != NULL);
- //if(!file->open(QIODevice::ReadWrite)) {
- // ui->statusLabel->setText("open error "+file->fileName());
- // return;
- //}
- //ui->statusLabel->setText("Upload start");
- //ftp->put(file,fileName);
- //ui->statusLabel->setText("Upload end");
- }
See the relevant lines up there. Everything else is converted to comments. You declare and use, but you do not assign any content. So, it has to be empty when used.
I understand your question now, thank you. When I do:
I see a list of files. My intention is to “double click” a file and use that to select
the fileName. How can I do that?
If I want to go to simpler route, can I just change the fileName to “myfile.txt”?
Ofcourse, I think then I wont need the “QFileDialog” thing, correct?
So I made some changes and it does not go to the error message anymore.
It now puts the file in the remote location.
- void FtpClientDlg::selectFile() {
- if (files.isEmpty())
- return;
- Q_ASSERT(file != NULL);
- ui->statusLabel->setText("open error "+file->fileName());
- return;
- }
- ui->statusLabel->setText("Upload start");
- ftp->put(file,fileName);
- ui->statusLabel->setText("Upload end");
- }
However, the Dialog window does not automatically update to show the new files. Any idea how to get that?
Which dialog window do you mean?
I guess you are talking about a different dialog window whose source you have not posted. This dialog window shall show the files on the ftp site?
The ftp is a command driven approach communicating with a remote site. Whatever you are doing, you have to send command for everything separately. So, if you like to have updated information of the ftp server content, you have to send another command to give you the list. Please consult QFtp [qt-project.org] documentation and probably you should also see at standard ftp approaches. Because QFtp is just providing the interface to do the same.
BTW QFtp is deprecated [qt-project.org] and you may want to have a look to QNetworkAccessManager and QNetworkReply.
You must log in to post a reply. Not a member yet? Register here!


