Any way to detect usb device and print his path in QML?
-
@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
Philippewrote on 3 Sept 2018, 12:10 last edited by@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... -
@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...wrote on 3 Sept 2018, 17:53 last edited by@Diracsbracket said in Any way to detect usb device and print his path in QML?:
Yes too bad.. I stay with my problem then... :..( -
@Diracsbracket said in Any way to detect usb device and print his path in QML?:
Yes too bad.. I stay with my problem then... :..(wrote on 3 Sept 2018, 18:01 last edited by Diracsbracket 9 Mar 2018, 18:06@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. -
@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.wrote on 3 Sept 2018, 22:46 last edited by@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 -
@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
Philippewrote on 4 Sept 2018, 01:44 last edited by Diracsbracket 9 Apr 2018, 02:42@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 -
@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.
Paulwrote on 4 Sept 2018, 06:59 last edited by@Diracsbracket Hello, I understand, thank you for your help.
Philippe
-
@Diracsbracket Hello, I understand, thank you for your help.
Philippe
wrote on 5 Sept 2018, 18:03 last edited by@filipdns if your issue is solved please don't forget to mark your post as such. Thanks
-
@filipdns if your issue is solved please don't forget to mark your post as such. Thanks
wrote on 6 Sept 2018, 07:43 last edited by@Pablo-J.-Rogina hello, that is not the case, I still trying to found solution.
Kind regards
Philippe -
@Pablo-J.-Rogina hello, that is not the case, I still trying to found solution.
Kind regards
Philippewrote on 6 Sept 2018, 08:28 last edited by Diracsbracket 9 Jun 2018, 08:30@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. -
@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.wrote on 6 Sept 2018, 09:10 last edited by@Diracsbracket hello, it probably working but I didn't understand how I have to work with yet...
-
@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.wrote on 6 Sept 2018, 09:36 last edited by@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
15/16