Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Detect SD card in Qt linux



  • Hello!!

    I need to detect a SD card inserted in the system in linux. I want to know the available storage for showing it in the interface.

    How can I work with this, because I tried with QStorageInfo but it couldn't detect it.

    Thank you very much!


  • Lifetime Qt Champion

    Hi @ivanicy,

    does Linux detect the SD card insertion?

    What does dmesg --follow print while you insert the SD card?

    Regards



  • [20515.536057] usb 7-2: new high-speed USB device number 10 using xhci_hcd
    [20515.697534] usb 7-2: New USB device found, idVendor=05e3, idProduct=0745
    [20515.697540] usb 7-2: New USB device strings: Mfr=0, Product=1, SerialNumber=2
    [20515.697543] usb 7-2: Product: USB Storage
    [20515.697546] usb 7-2: SerialNumber: 000000000902
    [20515.699125] usb-storage 7-2:1.0: USB Mass Storage device detected
    [20515.699421] scsi host8: usb-storage 7-2:1.0
    [20516.717964] scsi 8:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0902 PQ: 0 ANSI: 6
    
    

    Ubuntu recognises the sd card but, I don't know how to obtain its information with qt


  • Lifetime Qt Champion

    @ivanicy

    Yeah, but it misses vital information. For me it looks like this:

    [153610.743719] usb-storage 3-2:1.0: USB Mass Storage device detected
    [153610.743841] scsi host4: usb-storage 3-2:1.0
    [153610.744018] usbcore: registered new interface driver usb-storage
    [153610.745940] usbcore: registered new interface driver uas
    [153611.958041] scsi 4:0:0:0: Direct-Access                               1100 PQ: 0 ANSI: 4
    [153611.958981] sd 4:0:0:0: Attached scsi generic sg2 type 0
    [153611.958995] sd 4:0:0:0: [sdc] 15810560 512-byte logical blocks: (8.10 GB/7.54 GiB)
    [153611.959453] sd 4:0:0:0: [sdc] Write Protect is off
    [153611.959460] sd 4:0:0:0: [sdc] Mode Sense: 43 00 00 00
    [153611.959975] sd 4:0:0:0: [sdc] No Caching mode page found
    [153611.959991] sd 4:0:0:0: [sdc] Assuming drive cache: write through
    [153611.970892]  sdc: sdc1
    [153611.972933] sd 4:0:0:0: [sdc] Attached SCSI removable disk
    

    Here you see, that a partition sdc was detected, and then the media was mounted into media/user/<device-id> (can be checked with mount).

    Is that the case for you too?

    Regards


  • Lifetime Qt Champion

    Hi,

    KDE's Solid library can help you there.


Log in to reply