본문 바로가기

QT20

[Qt] QMovie로 gif 재생이 안 될 때 ..... 아래와 같이 QMovie를 사용하여 gif 재생을 시켜보자. #include "mainwindow.h" #include "ui_mainwindow.h" #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QMovie* gifPlay = new QMovie(":images/images/loading.gif"); ui->label->setMovie(gifPlay); gifPlay->start(); } MainWindow::~MainWindow() { delete ui; } 3줄로 간단하게 gif 재생을 할 수 있다. 그런데.... 재생이 안된다... 이.. 2023. 8. 7.
[QT] 드라이브 목록 출력하기 (QStorageInfo) QStorageInfo를 사용하여 드라이브 목록 출력하기 샘플 코드 #include #include #include #include int run_main() { foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) { if (storage.isValid() && storage.isReady()) { if (!storage.isReadOnly()) { qDebug() 2023. 4. 5.
[QT] Json array 읽기 아래와 같은 Json array 읽기 예제 QT의 Json Class를 사용해서 아래와 같이 쉽게 읽을 수 있음. 예제 코드 #include #include #include #include #include #include #if 0 { "name" : "busyman", "yyyymmdd" : "19850101", "list" : [ { "name" : "apple", "price" : 9900 }, { "name" : "banana", "price" : 5000 } ] } #endif class fruitInfo { public: fruitInfo() { price = 0; } ~fruitInfo() {} QJsonObject toJson() const { return {{"name", name}, {.. 2023. 3. 4.
[QT] 공백 (whitespace) 제거 QT에서 공백 지우기는 간단하다. 공백만 지운다면 remove()를 사용하고 탭 또는 개행과 같은 문자까지 지우려면 simplified()를 같이 사용하면 된다. 단, 주의할 점은 두 함수가 어떻게 생겼냐는 것이다. simplified()는 QString를 반환하고 QString simplified() const replace는 QString&를 반환한다. QString& replace(const QChar *before, qsizetype blen, const QChar *after, qsizetype alen, Qt::CaseSensitivity cs = Qt::CaseSensitive) 따라서, 아래와 같이 쓰는 실수를 해서는 안된다. QString testString4 = testString.si.. 2023. 2. 11.