Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFSFileEngine::open: No file name specified
Forum Updated to NodeBB v4.3 + New Features

QFSFileEngine::open: No file name specified

Scheduled Pinned Locked Moved General and Desktop
8 Posts 1 Posters 43.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on 29 Apr 2012, 19:25 last edited by
    #1

    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:

    @QFSFileEngine::open: No file name specified@

    Here is the code snippet:

    @void FtpClientDlg::selectFile() {
    QString fileName;
    QString files = QFileDialog::getOpenFileName(this, tr("Select File"), "/");
    if (files.isEmpty())
    return;
    file = new QFile(fileName);
    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");
    }@

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on 29 Apr 2012, 19:43 last edited by
      #2

      Where do you assign a file name to "fileName"?
      This string has to be empty when used.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on 29 Apr 2012, 20:07 last edited by
        #3

        I am trying to follow an example, so I am not sure I understand the code very well. What should I be looking for?

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on 29 Apr 2012, 20:12 last edited by
          #4

          From what I understand, this part is not working correctly:

          @file = new QFile(fileName);@

          Which is why I am getting the error message. I looked at other examples
          and the formating seems similar, so I am not sure what is wrong where.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on 29 Apr 2012, 20:36 last edited by
            #5

            @void FtpClientDlg::selectFile() {
            QString fileName;
            // QString files = QFileDialog::getOpenFileName(this, tr("Select File"), "/");
            // if (files.isEmpty())
            // return;
            file = new QFile(fileName);
            // 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.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on 29 Apr 2012, 20:51 last edited by
              #6

              I understand your question now, thank you. When I do:

              @QString files = QFileDialog::getOpenFileName(this, tr("Select File"), "/");@

              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?

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on 29 Apr 2012, 21:34 last edited by
                #7

                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() {

                • QString files = QFileDialog::getOpenFileName(this, tr("Select File"), "/");
                  if (files.isEmpty())
                  return;
                QString fileName = QFileInfo(files).fileName();
                
                file = new QFile(fileName);
                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");
                

                }@

                However, the Dialog window does not automatically update to show the new files. Any idea how to get that?

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on 30 Apr 2012, 17:11 last edited by
                  #8

                  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":http://qt-project.org/doc/qt-4.8/qftp.html#list 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":http://qt-project.org/doc/qt-4.8/qftp.html#details and you may want to have a look to QNetworkAccessManager and QNetworkReply.

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0

                  1/8

                  29 Apr 2012, 19:25

                  • Login

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved