久久久久久久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 友好的方式進行.

我看了QDir、QFile、QFileInfo——什么都沒有!

解決方案

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

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

QStorageInfo storage = QStorageInfo::root();qDebug() <<storage.rootPath();如果 (storage.isReadOnly())qDebug() <<是只讀的:"<<storage.isReadOnly();qDebug() <<姓名:"<<存儲名稱();qDebug() <<文件系統(tǒng)類型:"<<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模板網(wǎng)!

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

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 一区二区三区在线观看免费 | 少妇一级片 | 免费黄色片视频 | 欧美日韩在线精品 | www一级片 | 黄色录像一级片 | 日本不卡高字幕在线2019 | 国产天天操 | 91久久精品日日躁夜夜躁欧美 | 精品蜜桃一区二区三区 | 秋霞一区二区 | 日韩av中文字幕在线播放 | 亚洲精品一区二区在线观看 | 国产91在线看 | 成人黄性视频 | 日韩毛片网 | 日韩在线播放视频 | 日韩欧美精品 | 中文字幕国产视频 | 亚洲天码中字 | 久久久久久久久久国产精品 | 91看片看淫黄大片 | 日韩午夜在线观看 | 偷拍福利视频 | 亚洲经典一区 | 欧美日韩在线视频观看 | 精品日韩在线 | 国产又猛又黄又爽 | 国内精品一区二区三区 | 日韩精品成人 | 国产一区视频在线 | 欧美不卡 | 成人h片在线观看 | 成人国产精品免费观看 | 丁香婷婷激情 | 欧美日韩无 | 亚洲精品1区2区 | 亚洲成人精品在线 | 美女福利视频 | 日韩欧美自拍 | 欧美日韩在线观看视频 |