조회 수 6929 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

QStorageInfo 클래스를 사용하면 하드디스크 정보를 가져와서 여유공간 등의 정보를 알 수 있다. 아래 예제에서는 애플리케이션이 Windows 볼륨(C:드라이브) 정보를 가져오는 방법을 보여준다.

#include <QDebug>

#include <QStorageInfo>

#define GB (1024 * 1024 * 1024)

void PrintVolumeInfo(const QString &drive)
{
    QStorageInfo storage(drive);
    if( storage.isValid() && storage.isReady() ) {
        qDebug() << "Name:" << storage.name();
        qDebug() << "Used:" << (storage.bytesTotal()-storage.bytesAvailable()) * 1.0 / GB << "GB";
        qDebug() << "Free:" << storage.bytesAvailable() * 1.0 / GB << "GB";
        qDebug() << "Total:" << storage.bytesTotal() * 1.0 / GB << "GB";
    }
}


...
PrintVolumeInfo("C:");
...

 

실행 결과는 다음과 같다.

QStorageInfo.png

TAG •

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 QML and Qt Quick Qt프로그래밍(QtQuick) Beginner를 위한 글 읽는 순서 운영자 2019.01.05 131106
180 Installation and Deployment Visual Studio Code용 Qt 확장팩 file makersweb 2024.10.09 7935
179 General and Desktop Qt 응용프로그램에 Web 구성 요소를 표시 with Servo file makersweb 2024.04.27 11401
178 Installation and Deployment Qt Creator 에서 GitHub Copilot 사용하기 file makersweb 2024.04.13 10500
177 QML and Qt Quick QtQuick 애플리케이션에 Rive 애니메이션 통합 makersweb 2024.03.31 5676
176 Installation and Deployment 클라우드용 Qt file makersweb 2024.01.16 6764
175 Qt 6 QRhi 에 대해서 file makersweb 2023.12.29 7829
174 Mobile and Embedded Android 애플리케이션 서명 구성 file makersweb 2023.12.17 7023
173 C++ Class QML의 사용자 정의 Image makersweb 2023.09.17 9952
172 C++ Class Base64로 인코딩된 파일을 복원 makersweb 2023.08.06 11805
171 QML and Qt Quick QML에서 D-Bus 통신 file makersweb 2023.03.15 6470
170 General and Desktop Qt 하이브리드 애플리케이션(Hybrid App) 개발 file makersweb 2023.02.08 7455
169 General and Desktop Widgets(C++) 기반의 기본 스타일을 Dark 테마 및 Material 디자인 스타일로 바꾸기 file makersweb 2023.01.28 11144
168 QML and Qt Quick OpacityMask 예제 file makersweb 2023.01.26 11076
167 C++ Class QProcess 예제 (프로그램 재시작) file makersweb 2023.01.25 5983
» C++ Class 하드디스크 드라이브 여유 공간 계산 file makersweb 2023.01.15 6929
165 General and Desktop Qt Property(속성) 시스템 makersweb 2023.01.08 9244
164 General and Desktop VTK 를 사용해서 강력한 시각화(3D, Plotting, Chart)Qt 응용프로그램 개발하기 file makersweb 2022.10.16 7988
163 General and Desktop QProcess 보안 권고 리뷰 file makersweb 2022.09.18 4381
162 Installation and Deployment QMake 프로젝트를 CMake 프로젝트로 변환 with qmake2cmake makersweb 2022.09.17 5055
161 Mobile and Embedded Qt Safe Renderer 개요 file makersweb 2022.09.08 7181
Board Pagination Prev 1 2 3 4 5 9 Next
/ 9