Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Any way to detect usb device and print his path in QML?
QtWS25 Last Chance

Any way to detect usb device and print his path in QML?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
16 Posts 4 Posters 4.7k 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.
  • F filipdns
    2 Sept 2018, 14:45

    @Diracsbracket Thanks a lot.

    Finaly I success to build it but still not able to use it yet.

    I make small test to try:

    First problem, I can not put QT += Solid on pro file because it return error:

    :-1: erreur : LNK1181: cannot open input file 'Files.obj'

    I try without with qml below:

    import QtQuick 2.11
    import QtQuick.Layouts 1.3
    import QtQuick.Controls 2.1
    import QtQuick.Controls.Styles 1.1
    import QtQuick.Extras 1.4
    import QtQuick.Controls 1.4
    import QtQuick.LocalStorage 2.0
    import QtQuick.Window 2.3
    import QtQml 2.11
    import QtQml.Models 2.11
    import org.kde.solid 1.0 as Solid
    
    Window {
        visible: true
        width: 640
        height: 480
        Rectangle{
            height:200
            width:200
    
            Solid.Devices {
                id: allDevices
                onDeviceAdded: console.log(allDevices.count)
                onCountChanged: {console.log(allDevices.count);number.text=allDevices.count}
                onDeviceRemoved: console.log(allDevices.count)
            }
    
            Text {
                id:number
                color:"black"
                text: allDevices.count
            }
        }
    }
    

    I got 13 display.

    with insert usb device, no signal, then nothing is return by the first part of the qml and the number display dosn't change.:

            Solid.Devices {
                id: allDevices
                onDeviceAdded: console.log(allDevices.count)
                onCountChanged: {console.log(allDevices.count);number.text=allDevices.count}
                onDeviceRemoved: console.log(allDevices.count)
            }
    

    but re-run the application, I got 15 display, and remove this device again and run again, I have again 13 display, then allDevices.count is working...

    So if you have more informations about Solid on .pro problem and about the signals problem, I will be happy to be informed ;-)

    best regards
    Philippe

    D Offline
    D Offline
    Diracsbracket
    wrote on 3 Sept 2018, 12:10 last edited by
    #6

    @filipdns
    I tried on both Windows 10 and Linux. Although the plugin builds,
    it just doesn't work as advertised, even for the simplest of examples.
    Too bad...

    F 1 Reply Last reply 3 Sept 2018, 17:53
    1
    • D Diracsbracket
      3 Sept 2018, 12:10

      @filipdns
      I tried on both Windows 10 and Linux. Although the plugin builds,
      it just doesn't work as advertised, even for the simplest of examples.
      Too bad...

      F Offline
      F Offline
      filipdns
      wrote on 3 Sept 2018, 17:53 last edited by
      #7

      @Diracsbracket said in Any way to detect usb device and print his path in QML?:
      Yes too bad.. I stay with my problem then... :..(

      D 1 Reply Last reply 3 Sept 2018, 18:01
      0
      • F filipdns
        3 Sept 2018, 17:53

        @Diracsbracket said in Any way to detect usb device and print his path in QML?:
        Yes too bad.. I stay with my problem then... :..(

        D Offline
        D Offline
        Diracsbracket
        wrote on 3 Sept 2018, 18:01 last edited by Diracsbracket 9 Mar 2018, 18:06
        #8

        @filipdns
        From
        https://stackoverflow.com/questions/29414329/is-there-a-qt-solution-for-detecting-usb-events-insertion-and-removal
        I just tried this one: it seems to work!
        https://github.com/wang-bin/qdevicewatcher
        You should be able to wrap it inside a QML class or pass it to the QML context.

        F 1 Reply Last reply 3 Sept 2018, 22:46
        3
        • D Diracsbracket
          3 Sept 2018, 18:01

          @filipdns
          From
          https://stackoverflow.com/questions/29414329/is-there-a-qt-solution-for-detecting-usb-events-insertion-and-removal
          I just tried this one: it seems to work!
          https://github.com/wang-bin/qdevicewatcher
          You should be able to wrap it inside a QML class or pass it to the QML context.

          F Offline
          F Offline
          filipdns
          wrote on 3 Sept 2018, 22:46 last edited by
          #9

          @Diracsbracket Thank you very much.

          I will check that tomorrow.

          Just in case and save time, do you know how I have to write the main.cpp with this qdevicewatcher to be able to receive the device path and the add and remove string to my qml?

          It's very small part of my project and if I can do not lost time for that it can be nice if you know what I mean ;-)

          Kind regards
          Philippe

          D 1 Reply Last reply 4 Sept 2018, 01:44
          0
          • F filipdns
            3 Sept 2018, 22:46

            @Diracsbracket Thank you very much.

            I will check that tomorrow.

            Just in case and save time, do you know how I have to write the main.cpp with this qdevicewatcher to be able to receive the device path and the add and remove string to my qml?

            It's very small part of my project and if I can do not lost time for that it can be nice if you know what I mean ;-)

            Kind regards
            Philippe

            D Offline
            D Offline
            Diracsbracket
            wrote on 4 Sept 2018, 01:44 last edited by Diracsbracket 9 Apr 2018, 02:42
            #10

            @filipdns said in Any way to detect usb device and print his path in QML?:

            It's very small part of my project and if I can do not lost time for that it can be nice if you know what I mean ;-)

            Sorry, I cannot spend more time on that either. But I'm sure you will find it very quickly. Tomorrow.
            It's not that difficult.

            Good luck.
            Paul

            F 1 Reply Last reply 4 Sept 2018, 06:59
            1
            • D Diracsbracket
              4 Sept 2018, 01:44

              @filipdns said in Any way to detect usb device and print his path in QML?:

              It's very small part of my project and if I can do not lost time for that it can be nice if you know what I mean ;-)

              Sorry, I cannot spend more time on that either. But I'm sure you will find it very quickly. Tomorrow.
              It's not that difficult.

              Good luck.
              Paul

              F Offline
              F Offline
              filipdns
              wrote on 4 Sept 2018, 06:59 last edited by
              #11

              @Diracsbracket Hello, I understand, thank you for your help.

              Philippe

              P 1 Reply Last reply 5 Sept 2018, 18:03
              0
              • F filipdns
                4 Sept 2018, 06:59

                @Diracsbracket Hello, I understand, thank you for your help.

                Philippe

                P Offline
                P Offline
                Pablo J. Rogina
                wrote on 5 Sept 2018, 18:03 last edited by
                #12

                @filipdns if your issue is solved please don't forget to mark your post as such. Thanks

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                F 1 Reply Last reply 6 Sept 2018, 07:43
                0
                • P Pablo J. Rogina
                  5 Sept 2018, 18:03

                  @filipdns if your issue is solved please don't forget to mark your post as such. Thanks

                  F Offline
                  F Offline
                  filipdns
                  wrote on 6 Sept 2018, 07:43 last edited by
                  #13

                  @Pablo-J.-Rogina hello, that is not the case, I still trying to found solution.

                  Kind regards
                  Philippe

                  D 1 Reply Last reply 6 Sept 2018, 08:28
                  0
                  • F filipdns
                    6 Sept 2018, 07:43

                    @Pablo-J.-Rogina hello, that is not the case, I still trying to found solution.

                    Kind regards
                    Philippe

                    D Offline
                    D Offline
                    Diracsbracket
                    wrote on 6 Sept 2018, 08:28 last edited by Diracsbracket 9 Jun 2018, 08:30
                    #14

                    @filipdns said in Any way to detect usb device and print his path in QML?:

                    that is not the case,

                    Does QDeviceWatcher not work? On my system, it correctly detects insertions and removals but maybe the ID's are not correctly reported as is.

                    F 2 Replies Last reply 6 Sept 2018, 09:10
                    1
                    • D Diracsbracket
                      6 Sept 2018, 08:28

                      @filipdns said in Any way to detect usb device and print his path in QML?:

                      that is not the case,

                      Does QDeviceWatcher not work? On my system, it correctly detects insertions and removals but maybe the ID's are not correctly reported as is.

                      F Offline
                      F Offline
                      filipdns
                      wrote on 6 Sept 2018, 09:10 last edited by
                      #15

                      @Diracsbracket hello, it probably working but I didn't understand how I have to work with yet...

                      1 Reply Last reply
                      0
                      • D Diracsbracket
                        6 Sept 2018, 08:28

                        @filipdns said in Any way to detect usb device and print his path in QML?:

                        that is not the case,

                        Does QDeviceWatcher not work? On my system, it correctly detects insertions and removals but maybe the ID's are not correctly reported as is.

                        F Offline
                        F Offline
                        filipdns
                        wrote on 6 Sept 2018, 09:36 last edited by
                        #16

                        @Diracsbracket About Id I don't need it, I need only to have drive path display in qml text... but in c++ I very beginner

                        1 Reply Last reply
                        0

                        15/16

                        6 Sept 2018, 09:10

                        • Login

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