#include <QStorageInfo>
#include <QDebug>
QList<QStorageInfo> storageInfoList = QStorageInfo::mountedVolumes();
foreach(QStorageInfo storage ,storageInfoList){
qDebug() << "盘符" <<storage.rootPath();
if (storage.isReadOnly())
qDebug() << "isReadOnly:" << storage.isReadOnly();
qDebug() << "fileSystemType:" << storage.fileSystemType();
qDebug() << "size:" << storage.bytesTotal()/1000/1000 << "MB";
qDebug() << "availableSize:" << storage.bytesAvailable()/1000/1000 << "MB";
}
output:
盘符 "C:/"
fileSystemType: "NTFS"
size: 107789 MB
availableSize: 38554 MB
盘符 "D:/"
fileSystemType: "NTFS"
size: 403254 MB
availableSize: 187184 MB