用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
[TOC] ## 概述 Qt 5.4.0 版本开始新增的类 ![](https://qtguide.ustclug.org/images/ch07/ch07-05-01.png) ![](https://qtguide.ustclug.org/images/ch07/ch07-05-02.png) 常用函数 ``` static QList<QStorageInfo> mountedVolumes() // 打印分区盘的消息 static QStorageInfo root(); 打印根分区 QStorageInfo::​QStorageInfo(const QString & path) QStorageInfo::​QStorageInfo(const QDir & dir) bool QStorageInfo::​isValid() const //当前分区是否已挂载到文件系统 bool QStorageInfo::​isReady() const //当前分区的文件系统是否正常工作 qint64 QStorageInfo::​bytesTotal() const //分区总大小,单位字节 qint64 QStorageInfo::​bytesFree() const //分区剩余空闲空间,单位字节 qint64 QStorageInfo::​bytesAvailable() const //当前用户可以使用该分区中多大空闲空间,单位字节 QByteArray QStorageInfo::​fileSystemType() const //Windows常见的文件系统类型是NTFS,Linux常用ext3等 QString QStorageInfo::​name() const //比如 C: 盘标签叫 System,D: 盘标签叫 Programs,标签名有可能为空 QString QStorageInfo::​displayName() const //有标签名就显示标签名,没标 签名显示盘符名 bool QStorageInfo::​isReadOnly() const //是否为只读分区或者无权限写入,如光盘分区 bool QStorageInfo::​isRoot() const //是否为操作系统安装的根 QByteArray QStorageInfo::​device() const //设备名,Linux系统常见为 /dev/sda\* ,Windows 是一长串设备代码 QString QStorageInfo::​rootPath() const //分区的挂载点 ``` ## 示例 ``` 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"; ```