found this thread and had the same problem (windows...)
Since Qt 5.4 you can use following:
http://doc.qt.io/qt-5/qstorageinfo.html#device
QByteArray QStorageInfo::device() const
Returns the device for this volume.
For example, on Unix filesystems (including OS X), this returns the devpath like [B]/dev/sda0[/B] for local storages.
On Windows, it returns the UNC path starting with [B]\\\\?\\ [/B]for local storages (in other words, the volume GUID).
Returns the device for this volume.
For example, on Unix filesystems (including OS X), this returns the devpath like [B]/dev/sda0[/B] for local storages.
On Windows, it returns the UNC path starting with [B]\\\\?\\ [/B]for local storages (in other words, the volume GUID).
To copy to clipboard, switch view to plain text mode
For example:
bool bLocalDrive = false;
QStorageInfo storage(qApp->applicationDirPath());
/*
storage.device() returns the device for this volume.
For example, on Unix filesystems (including OS X), this returns the devpath like /dev/sda0 for local storages.
On Windows, it returns the UNC path starting with \\\\?\\ for local storages (in other words, the volume GUID).
*/
#ifdef Q_OS_WIN
if (qbaPath.startsWith("\\\\?\\"))
bLocalDrive = true;
#else
if (qbaPath.startsWith("/dev/sda0"))
bLocalDrive = true;
#endif
bool bLocalDrive = false;
QStorageInfo storage(qApp->applicationDirPath());
/*
storage.device() returns the device for this volume.
For example, on Unix filesystems (including OS X), this returns the devpath like /dev/sda0 for local storages.
On Windows, it returns the UNC path starting with \\\\?\\ for local storages (in other words, the volume GUID).
*/
QByteArray qbaPath = storage.device();
#ifdef Q_OS_WIN
if (qbaPath.startsWith("\\\\?\\"))
bLocalDrive = true;
#else
if (qbaPath.startsWith("/dev/sda0"))
bLocalDrive = true;
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks