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 read data from the usb drive?
Qt 6.11 is out! See what's new in the release blog

How to read data from the usb drive?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 3.8k 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.
  • J Offline
    J Offline
    Jimit Rupani
    wrote on last edited by
    #1

    I'd like to read data from a USB drive which is connected to the embedded Linux board or normal PC USB Port.

    1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      Hi,
      It is very easy, u just have to use FolderListModel, here official doc:
      http://doc.qt.io/qt-5/qml-qt-labs-folderlistmodel-folderlistmodel.html
      LA

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        As any other file in any other place you can use QFile

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        J 1 Reply Last reply
        2
        • VRoninV VRonin

          As any other file in any other place you can use QFile

          J Offline
          J Offline
          Jimit Rupani
          wrote on last edited by
          #4

          @VRonin I have used that to copy files to the USB but now I want to read those files from USB I mean I don't want to copy back to PC I just wanna see what is inside that folder.

          VRoninV 1 Reply Last reply
          0
          • J Jimit Rupani

            @VRonin I have used that to copy files to the USB but now I want to read those files from USB I mean I don't want to copy back to PC I just wanna see what is inside that folder.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            Yep, that's what QFile, QDir and friends do

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            J 1 Reply Last reply
            0
            • VRoninV VRonin

              Yep, that's what QFile, QDir and friends do

              J Offline
              J Offline
              Jimit Rupani
              wrote on last edited by
              #6

              @VRonin But i can't read those files its just like moving them to one place to another with QFile. I want to read file this time but.

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by VRonin
                #7
                QFile myFileOnUSB("D:/FolderOnUSBDrive/someFile.txt");
                if(myFileOnUSB.open(QFile::ReadOnly | QFile::Text)){
                QTextStream textReader(&myFileOnUSB);
                QString line;
                while (textReader.readLineInto(&line)) 
                qDebug() << line;
                }
                

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                3

                • Login

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