QStorageInfo Class
Provides information about currently mounted storage and drives. More...
| Header: | #include <QStorageInfo> |
| qmake: | QT += core |
| Since: | Qt 5.4 |
This class was introduced in Qt 5.4.
Detailed Description
Allows retrieving information about the volume's space, its mount point, label, and filesystem name.
You can create an instance of QStorageInfo by passing the path to the volume's mount point as a constructor parameter, or you can set it using the setPath() method. The static mountedVolumes() method can be used to get the list of all mounted filesystems.
QStorageInfo always caches the retrieved information, but you can call refresh() to invalidate the cache.
The following example retrieves the most common information about the root volume of the system, and prints information about it.
QStorageInfo storage = QStorageInfo::root();
qDebug() << storage.rootPath();
if (storage.isReadOnly())
qDebug() << "isReadOnly:" << storage.isReadOnly();
qDebug() << "name:" << storage.name();
qDebug() << "fileSystemType:" << storage.fileSystemType();
qDebug() << "size:" << storage.bytesTotal()/1000/1000 << "MB";
qDebug() << "availableSize:" << storage.bytesAvailable()/1000/1000 << "MB";