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

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

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

Qt Widgets 기반의 응용프로그램을 개발할 때 Qt 스타일 시트를 작성하여 스타일을 사용자 정의할 수 있다. Qt 스타일 시트는 QStyle을 서브클래싱하여 위젯의 모양을 사용자 정의할 수 있는 강력한 메커니즘이다.

다음의 간단한 예제는 응용 프로그램에서 모든 QLineEdit 의 배경색을 노란색으로 설정한다.

qApp->setStyleSheet("QLineEdit { background-color: yellow }");

특정 대화 상자의 자식(또는 손자 또는 손자들)인 QLineEdit에만 속성을 적용하려면 다음과 같이 한다.

myDialog->setStyleSheet("QLineEdit { background-color: yellow }");

Qt 스타일 시트의 구문 규칙이 CSS와 거의 동일하기 때문에 이미 CSS를 알고 있다면 빠르게 작성할 수 있겠지만 처음이라면 어려울 수 있다. 하지만 누군가가 이미 작성해서 공개한 Qt-Material 를 사용하면 쉽게 Dark테마 와 Material 디자인 스타일로 바꿀 수 있다. 다음은 런타임에 동적으로 스타일을 바꾸는 것을 보여 준다.

 

qt-material_example.zip

 

다음과 같이 런타임중에 stylesheet 파일을 읽어 바꿀 수 있다.

...
QFile f(":resource/theme/style.qss");

if (!f.exists())   {
    printf("Unable to set stylesheet, file not found\n");
}

else   {
    f.open(QFile::ReadOnly | QFile::Text);
    QTextStream ts(&f);
    qApp->setStyleSheet(ts.readAll());
}
...

 

https://github.com/UN-GCPDS/qt-material

https://github.com/ColinDuquesnoy/QDarkStyleSheet


  1. No Image notice

    Qt프로그래밍(QtQuick) Beginner를 위한 글 읽는 순서

    Date2019.01.05 CategoryQML and Qt Quick By운영자 Views109965
    read more
  2. Visual Studio Code용 Qt 확장팩

    Date2024.10.09 CategoryInstallation and Deployment Bymakersweb Views3027
    Read More
  3. Qt 응용프로그램에 Web 구성 요소를 표시 with Servo

    Date2024.04.27 CategoryGeneral and Desktop Bymakersweb Views3669
    Read More
  4. Qt Creator 에서 GitHub Copilot 사용하기

    Date2024.04.13 CategoryInstallation and Deployment Bymakersweb Views4232
    Read More
  5. No Image

    QtQuick 애플리케이션에 Rive 애니메이션 통합

    Date2024.03.31 CategoryQML and Qt Quick Bymakersweb Views2831
    Read More
  6. 클라우드용 Qt

    Date2024.01.16 CategoryInstallation and Deployment Bymakersweb Views3201
    Read More
  7. QRhi 에 대해서

    Date2023.12.29 CategoryQt 6 Bymakersweb Views2836
    Read More
  8. Android 애플리케이션 서명 구성

    Date2023.12.17 CategoryMobile and Embedded Bymakersweb Views3241
    Read More
  9. No Image

    QML의 사용자 정의 Image

    Date2023.09.17 CategoryC++ Class Bymakersweb Views3676
    Read More
  10. No Image

    Base64로 인코딩된 파일을 복원

    Date2023.08.06 CategoryC++ Class Bymakersweb Views2527
    Read More
  11. QML에서 D-Bus 통신

    Date2023.03.15 CategoryQML and Qt Quick Bymakersweb Views3175
    Read More
  12. Qt 하이브리드 애플리케이션(Hybrid App) 개발

    Date2023.02.08 CategoryGeneral and Desktop Bymakersweb Views3601
    Read More
  13. No Image

    Widgets(C++) 기반의 기본 스타일을 Dark 테마 및 Material 디자인 스타일로 바꾸기

    Date2023.01.28 CategoryGeneral and Desktop Bymakersweb Views5677
    Read More
  14. OpacityMask 예제

    Date2023.01.26 CategoryQML and Qt Quick Bymakersweb Views3796
    Read More
  15. QProcess 예제 (프로그램 재시작)

    Date2023.01.25 CategoryC++ Class Bymakersweb Views3787
    Read More
  16. 하드디스크 드라이브 여유 공간 계산

    Date2023.01.15 CategoryC++ Class Bymakersweb Views2988
    Read More
  17. No Image

    Qt Property(속성) 시스템

    Date2023.01.08 CategoryGeneral and Desktop Bymakersweb Views5330
    Read More
  18. VTK 를 사용해서 강력한 시각화(3D, Plotting, Chart)Qt 응용프로그램 개발하기

    Date2022.10.16 CategoryGeneral and Desktop Bymakersweb Views4263
    Read More
  19. QProcess 보안 권고 리뷰

    Date2022.09.18 CategoryGeneral and Desktop Bymakersweb Views2637
    Read More
  20. No Image

    QMake 프로젝트를 CMake 프로젝트로 변환 with qmake2cmake

    Date2022.09.17 CategoryInstallation and Deployment Bymakersweb Views3354
    Read More
  21. Qt Safe Renderer 개요

    Date2022.09.08 CategoryMobile and Embedded Bymakersweb Views2711
    Read More
Board Pagination Prev 1 2 3 4 5 9 Next
/ 9