久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何確定Qt驅動器上有多少可用空間?

How to determine how much free space on a drive in Qt?(如何確定Qt驅動器上有多少可用空間?)
本文介紹了如何確定Qt驅動器上有多少可用空間?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 Qt 并且想要一種獨立于平臺的方式來獲取可用的可用磁盤空間.

我知道在 Linux 中我可以使用 statfs,而在 Windows 中我可以使用 GetDiskFreeSpaceEx().我知道 boost 有一種方法,boost::filesystem::space(Path const & p).

但我不想要那些.我在 Qt 中,并希望以 Qt 友好的方式進行.

我看了QDirQFileQFileInfo——什么都沒有!

解決方案

我知道這是一個很老的話題,但仍然有人覺得它很有用.

自 QT 5.4 起,QSystemStorageInfo 已停止使用,取而代之的是一個新類 QStorageInfo,它使整個任務變得非常簡單并且是跨平臺的.

QStorageInfo storage = QStorageInfo::root();qDebug() <<storage.rootPath();如果 (storage.isReadOnly())qDebug() <<是只讀的:"<<storage.isReadOnly();qDebug() <<姓名:"<<存儲名稱();qDebug() <<文件系統類型:"<<storage.fileSystemType();qDebug() <<尺寸:"<<storage.bytesTotal()/1000/1000 <<"MB";qDebug() <<可用大小:"<<storage.bytesAvailable()/1000/1000 <<"MB";

<塊引用>

已從QT 5.5 文檔

中的示例中復制代碼

I'm using Qt and want a platform-independent way of getting the available free disk space.

I know in Linux I can use statfs and in Windows I can use GetDiskFreeSpaceEx(). I know boost has a way, boost::filesystem::space(Path const & p).

But I don't want those. I'm in Qt and would like to do it in a Qt-friendly way.

I looked at QDir, QFile, QFileInfo -- nothing!

解決方案

I know It's quite old topic but somebody can still find it useful.

Since QT 5.4 the QSystemStorageInfo is discontinued, instead there is a new class QStorageInfo that makes the whole task really simple and it's cross-platform.

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";

Code has been copied from the example in QT 5.5 docs

這篇關于如何確定Qt驅動器上有多少可用空間?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 亚洲精品久久久久久一区二区 | 成人av高清 | 亚洲免费视频网站 | 99re视频精品| 欧美vide| 日韩视频中文字幕 | 欧美一区二区三区视频在线观看 | 日本午夜网 | 亚洲乱码国产乱码精品精98午夜 | 看片一区 | 久久综合一区 | 精久久久 | 成人免费视频一区 | a看片| 午夜成人在线视频 | av黄色网 | 中文字幕成人网 | 国产在线一区二区 | 日本亚洲欧美 | 综合久久99 | 成人激情视频 | 欧美极品在线观看 | 亚洲精品中文字幕中文字幕 | 欧美国产精品一区二区三区 | 一二区视频 | 亚洲欧美一区二区三区国产精品 | 久久久久久综合 | 妞干网av | 欧美在线日韩 | 国产一区二区影院 | 四虎影院在线观看免费视频 | 午夜电影在线播放 | 欧美精品1区 | 色在线免费 | 精品国产一区二区三区日日嗨 | 中文字幕一区二区在线观看 | 一区二区三区福利视频 | 欧美日韩看片 | 青青草视频网 | 国产高清在线精品 | 91在线精品视频 |