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. QFtp list()
Forum Updated to NodeBB v4.3 + New Features

QFtp list()

Scheduled Pinned Locked Moved Unsolved General and Desktop
30 Posts 3 Posters 9.0k Views 2 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.
  • M magguz

    @mrjj

    And how I can get the content of a directory on a FTP-server as a string?

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #15

    @magguz
    for each file it will send event listInfo() signal so you need to connect to that and build a string yourself if you want
    that.
    void QFtp::listInfo(const QUrlInfo & i)

    so you get a QUrlInfo pr file.
    you can ask for string with
    QString QUrlInfo::name() const

    "The listInfo() signal is emitted for each directory entry found."

    M 1 Reply Last reply
    0
    • mrjjM mrjj

      @magguz
      for each file it will send event listInfo() signal so you need to connect to that and build a string yourself if you want
      that.
      void QFtp::listInfo(const QUrlInfo & i)

      so you get a QUrlInfo pr file.
      you can ask for string with
      QString QUrlInfo::name() const

      "The listInfo() signal is emitted for each directory entry found."

      M Offline
      M Offline
      magguz
      wrote on last edited by
      #16

      @mrjj

      I have now created a second connect method and a function "addToList()" like this:

      connect(m_ftp, SIGNAL(listInfo()), this, SLOT(addToList()));
      

      and now?

      mrjjM 1 Reply Last reply
      0
      • M magguz

        @mrjj

        I have now created a second connect method and a function "addToList()" like this:

        connect(m_ftp, SIGNAL(listInfo()), this, SLOT(addToList()));
        

        and now?

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #17

        @magguz
        HGi
        its :listInfo(const QUrlInfo & i)
        so syntax is not correct

        connect(m_ftp, SIGNAL(listInfo(const QUrlInfo &), this, SLOT(addToList(const QUrlInfo &));
        and change addToList so it takes that parameter.
        For each file it calls it
        and you can build your list or what you need.

        M 1 Reply Last reply
        0
        • mrjjM mrjj

          @magguz
          HGi
          its :listInfo(const QUrlInfo & i)
          so syntax is not correct

          connect(m_ftp, SIGNAL(listInfo(const QUrlInfo &), this, SLOT(addToList(const QUrlInfo &));
          and change addToList so it takes that parameter.
          For each file it calls it
          and you can build your list or what you need.

          M Offline
          M Offline
          magguz
          wrote on last edited by
          #18

          @mrjj said in QFtp list():

          @magguz

          and change addToList so it takes that parameter.

          how I can take the parameter into the addToList function?

          mrjjM 1 Reply Last reply
          0
          • M magguz

            @mrjj said in QFtp list():

            @magguz

            and change addToList so it takes that parameter.

            how I can take the parameter into the addToList function?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #19

            @magguz
            just change the addToList so it the real slot have a variable name.
            (not in the connect. they are always without names)

            void addToList(const QUrlInfo & file);

            M 1 Reply Last reply
            0
            • mrjjM mrjj

              @magguz
              just change the addToList so it the real slot have a variable name.
              (not in the connect. they are always without names)

              void addToList(const QUrlInfo & file);

              M Offline
              M Offline
              magguz
              wrote on last edited by
              #20

              @mrjj

              I changed the addToList() to addToList(const QUrlInfo & file)
              Now I get an object named "file" for every directory entry, right?

              mrjjM 1 Reply Last reply
              0
              • M magguz

                @mrjj

                I changed the addToList() to addToList(const QUrlInfo & file)
                Now I get an object named "file" for every directory entry, right?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #21

                @magguz
                yes you get an URL object for each file
                and the (QUrlInfo) file has a function called
                name() that returns a QString.

                http://doc.qt.io/archives/qt-4.8/qurlinfo.html

                M 1 Reply Last reply
                0
                • mrjjM mrjj

                  @magguz
                  yes you get an URL object for each file
                  and the (QUrlInfo) file has a function called
                  name() that returns a QString.

                  http://doc.qt.io/archives/qt-4.8/qurlinfo.html

                  M Offline
                  M Offline
                  magguz
                  wrote on last edited by
                  #22

                  @mrjj

                  now I want to append the strings to a textEdit like this:

                  ui->textEdit->append(file.name());
                  

                  but it doesn't work

                  mrjjM 1 Reply Last reply
                  0
                  • M magguz

                    @mrjj

                    now I want to append the strings to a textEdit like this:

                    ui->textEdit->append(file.name());
                    

                    but it doesn't work

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #23

                    @magguz
                    in what way "doesn't work" ?
                    What does it append?
                    is the addToList called ?

                    M 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @magguz
                      in what way "doesn't work" ?
                      What does it append?
                      is the addToList called ?

                      M Offline
                      M Offline
                      magguz
                      wrote on last edited by
                      #24

                      @mrjj said in QFtp list():

                      @magguz
                      in what way "doesn't work" ?
                      What does it append?
                      is the addToList called ?

                      no it seems that addToList is not called. It appends nothing.

                      mrjjM 1 Reply Last reply
                      0
                      • M magguz

                        @mrjj said in QFtp list():

                        @magguz
                        in what way "doesn't work" ?
                        What does it append?
                        is the addToList called ?

                        no it seems that addToList is not called. It appends nothing.

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #25

                        @magguz
                        well check all your connects like
                        qDebug() << "status:" << connect(xxxx); // xxxx being what u have
                        and see they return true.
                        also test that it does connect to the server. check errors and such.

                        M 1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @magguz
                          well check all your connects like
                          qDebug() << "status:" << connect(xxxx); // xxxx being what u have
                          and see they return true.
                          also test that it does connect to the server. check errors and such.

                          M Offline
                          M Offline
                          magguz
                          wrote on last edited by
                          #26

                          @mrjj

                          I found what was wrong. I changed

                          ftp->login("","");
                          

                          in

                          ftp->login();
                          

                          and it works. Thanks for your help!

                          1 Reply Last reply
                          1
                          • M Offline
                            M Offline
                            magguz
                            wrote on last edited by
                            #27

                            There is still one thing: In the TextEdit he lists all entries sixteen times

                            mrjjM 1 Reply Last reply
                            0
                            • M magguz

                              There is still one thing: In the TextEdit he lists all entries sixteen times

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #28

                              @magguz
                              Hi
                              well
                              what does file.name() contains ?
                              in
                              ui->textEdit->append(file.name());

                              I cant guess , please debug it using the debugger so you can see what happens.

                              M 1 Reply Last reply
                              1
                              • mrjjM mrjj

                                @magguz
                                Hi
                                well
                                what does file.name() contains ?
                                in
                                ui->textEdit->append(file.name());

                                I cant guess , please debug it using the debugger so you can see what happens.

                                M Offline
                                M Offline
                                magguz
                                wrote on last edited by
                                #29

                                @mrjj

                                I changed the connect statements like this:

                                connect(ftp, SIGNAL(listInfo(const QUrlInfo &)), this, SLOT(addToList(const QUrlInfo &)), Qt::UniqueConnection);
                                

                                I added only Qt::UniqueConnection as parameter. Now everything is fine :-)

                                mrjjM 1 Reply Last reply
                                1
                                • M magguz

                                  @mrjj

                                  I changed the connect statements like this:

                                  connect(ftp, SIGNAL(listInfo(const QUrlInfo &)), this, SLOT(addToList(const QUrlInfo &)), Qt::UniqueConnection);
                                  

                                  I added only Qt::UniqueConnection as parameter. Now everything is fine :-)

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #30

                                  @magguz
                                  Ahh, you might have added the connect many times :)
                                  well UniqueConnection solves also :)

                                  1 Reply Last reply
                                  0

                                  • Login

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