C++ Class
2019.11.05 22:54

QPushButton 의 커스텀 이미지버튼

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

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

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

C++ Class Qt 응용프로그램을 개발할 때 사용자정의 이미지버튼을 만드는 방법은 여러가지가 있지만 기본은 QWidget을 서브클래싱하여 구현한다. 위젯 기반의 Qt응용프로그램 개발에서 자주 사용되는 QPushButton이 있는데 QPushButton 클래스 또한 QWidget 을 기반으로 두고있음을 알 수 있다.

 

간단한 이미지 버튼을 만드는 방법중에 QPushButton을 사용하는 방법으로 Qt Style Sheet를 이용하면 간단하게 구현할 수 있다. Qt Style Sheets는 위젯의 모양을 사용자 정의하여 다양한 형태로 바꿀 수 있다. https://doc.qt.io/qt-5/stylesheet-reference.html

 

다음은 버튼을 클릭하지 않았을 때의 normal상태와 클릭했을때의 pressed 상태의 이미지 버튼을 구현하는 간단한 예제이다.

QPushButton *mybutton = new QPushButton(this);

mybutton->setStyleSheet(
            "                                  \
            QPushButton {                      \
                border-image: url(:/normal.png); \
                background-repeat: no-repeat;  \
            }                                  \
                                                \
            QPushButton:pressed {              \
                border-image: url(:/pressed.png); \
                background-repeat: no-repeat;  \
            }                                  \
            ");

mybutton->setGeometry(0, 0, 45, 131);

 

다음과 같이 간단한 사용자 정의 이미지 버튼을 만들 수 있다.

makerswebImageButton.gif


  1. No Image notice

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

    Date2019.01.05 CategoryQML and Qt Quick By운영자 Views436413
    read more
  2. Qt의 오픈소스 라이센스 소개

    Date2019.12.15 CategoryGeneral and Desktop Bymakersweb Views21857
    Read More
  3. No Image

    Qt for MCU 1.0 릴리즈

    Date2019.12.10 CategoryMobile and Embedded Bymakersweb Views15443
    Read More
  4. No Image

    Qt Marketplace 발표

    Date2019.12.02 CategoryGeneral and Desktop Bymakersweb Views8648
    Read More
  5. No Image

    QScopedPointer 소개 및 사용법

    Date2019.11.29 CategoryC++ Class Bymakersweb Views8029
    Read More
  6. QOpenVirtualkeyboard(Qt 5용 한글 및 영문, 숫자 가상키보드)

    Date2019.11.27 CategoryGeneral and Desktop Bymakersweb Views7760
    Read More
  7. Qt3D의 QML 타입으로 3D렌더링

    Date2019.11.20 CategoryQML and Qt Quick Bymakersweb Views9343
    Read More
  8. No Image

    라즈베리파이3에서 Boot to Qt 실행해보기

    Date2019.11.13 CategoryMobile and Embedded Bymakersweb Views9713
    Read More
  9. No Image

    Qt애플리케이션 객체(QCoreApplication, QGuiApplication, QApplication) 에 대해서

    Date2019.11.11 CategoryC++ Class Bymakersweb Views23956
    Read More
  10. No Image

    Qt Quick 3D 소개

    Date2019.11.09 CategoryQML and Qt Quick Bymakersweb Views12389
    Read More
  11. QPushButton 의 커스텀 이미지버튼

    Date2019.11.05 CategoryC++ Class Bymakersweb Views15543
    Read More
  12. qbs 사용 방법(Helloworld)

    Date2019.10.23 CategoryInstallation and Deployment Bymakersweb Views8584
    Read More
  13. 웹기반 Qt Design Viewer

    Date2019.10.23 CategoryQML and Qt Quick Bymakersweb Views11731
    Read More
  14. Qt Creator에서 Qt의존성 라이브러리 자동복사하기

    Date2019.10.19 CategoryInstallation and Deployment Bymakersweb Views12801
    Read More
  15. No Image

    Qt for Embedded Linux 화면출력

    Date2019.10.17 CategoryMobile and Embedded Bymakersweb Views11514
    Read More
  16. Windows에서 Qt 설치 따라하기

    Date2019.10.14 CategoryInstallation and Deployment Bymakersweb Views42665
    Read More
  17. Qbs 프로젝트를 정의하기 위해 사용되는 몇가지 중요한 아이템들

    Date2019.10.13 CategoryInstallation and Deployment Bymakersweb Views9974
    Read More
  18. No Image

    많은 리소스를 사용하는 Qt프로젝트에서 고려해봐야 할 qmake 옵션

    Date2019.10.11 CategoryGeneral and Desktop Bymakersweb Views10078
    Read More
  19. No Image

    Qbs에 대한 소개와 설치하는 방법

    Date2019.10.09 CategoryInstallation and Deployment Bymakersweb Views9026
    Read More
  20. OpenGL 렌더링을 QtQuick과 통합하는 방법

    Date2019.10.01 CategoryQML and Qt Quick Bymakersweb Views8964
    Read More
  21. No Image

    QML내에서의 시그널, 슬롯 시스템

    Date2019.09.29 CategoryQML and Qt Quick Bymakersweb Views12878
    Read More
Board Pagination Prev 1 3 4 5 6 7 9 Next
/ 9