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. How to search file name and making into the TXT file

How to search file name and making into the TXT file

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 606 Views
  • 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.
  • R Offline
    R Offline
    RiceBall
    wrote on last edited by
    #1

    I want to search specify file name and make the name to the bat file.
    Now I can make a file name is auto.bat.
    And make the first sentence AUTOLOAD.BAT
    Following is my code.

    QFile file("auto.bat");                                    //建立或開啟auto.bat檔案
        file.open(QIODevice::WriteOnly);                           //開啟檔案
        const char *data = "AUTOLOAD.BAT";                         //建立第一個字串AUTOLOAD.BAT
        file.write(data);
        file.close();
    

    Now I want to search specify file name (.B) and make sentence under the first.

      QStringList QfilterB("*.B*");                              //指定要篩選的字串
       foreach(QFileInfo Bitm, mDir.entryInfoList(QfilterB))
       {
            file.write(Bitm.fileName().toStdString);
       }
    

    It shown alarm like this. How could I fix it ??

    0_1557506017680_3777b1a3-bfbd-4e11-9fac-9e67e7eadc4a-image.png

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      "QString::toStdString" is a reference to a function, "QString::toStdString()" is a function call.
      But you're looking for QString::toUtf8()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      R 1 Reply Last reply
      4
      • Christian EhrlicherC Christian Ehrlicher

        "QString::toStdString" is a reference to a function, "QString::toStdString()" is a function call.
        But you're looking for QString::toUtf8()

        R Offline
        R Offline
        RiceBall
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in How to search file name and making into the TXT file:

        "QString::toStdString" is a reference to a function, "QString::toStdString()" is a function call.
        But you're looking for QString::toUtf8()

        When I change to String() , it will shown
        0_1557531986422_cfd772f2-119b-4df8-9b4b-7e5364b190c8-image.png

        How could I fix it ??

        aha_1980A 1 Reply Last reply
        0
        • R RiceBall

          @Christian-Ehrlicher said in How to search file name and making into the TXT file:

          "QString::toStdString" is a reference to a function, "QString::toStdString()" is a function call.
          But you're looking for QString::toUtf8()

          When I change to String() , it will shown
          0_1557531986422_cfd772f2-119b-4df8-9b4b-7e5364b190c8-image.png

          How could I fix it ??

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @RiceBall

          But you're looking for QString::toUtf8()

          Qt has to stay free or it will die.

          R 1 Reply Last reply
          3
          • aha_1980A aha_1980

            @RiceBall

            But you're looking for QString::toUtf8()

            R Offline
            R Offline
            RiceBall
            wrote on last edited by
            #5

            @aha_1980
            @Christian-Ehrlicher

            Thank you for your help.
            I solved it.

            0_1557585195473_f471e13d-6df9-4d74-9b80-f2fb6799eb0b-image.png

            1 Reply Last reply
            1

            • Login

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