QStylePainter Class
Q스타일페인터 클래스는 위젯 안에 QStyle 요소를 그리기 위한 편의 클래스입니다. 더 보기...
Header: | #include <QStylePainter> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
상속합니다: | QPainter |
- 상속된 멤버를 포함한 모든 멤버 목록
- Q스타일페인터는 페인팅 클래스의 일부입니다.
공용 함수
QStylePainter() | |
QStylePainter(QWidget *widget) | |
QStylePainter(QPaintDevice *pd, QWidget *widget) | |
bool | begin(QWidget *widget) |
bool | begin(QPaintDevice *pd, QWidget *widget) |
void | drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &option) |
void | drawControl(QStyle::ControlElement ce, const QStyleOption &option) |
void | drawItemPixmap(const QRect &rect, int flags, const QPixmap &pixmap) |
void | drawItemText(const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) |
void | drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &option) |
QStyle * | style() const |
자세한 설명
QStylePainter는 QPainter 을 확장하여 QStyle 의 API 위에 구현된 일련의 상위 수준 draw...()
함수를 제공합니다. QStylePainter를 사용하면 매개변수 목록이 상당히 짧아진다는 장점이 있습니다. QStyle 객체는 모든 페인터를 사용하여 모든 위젯에 그릴 수 있어야 하지만(일반적으로 애플리케이션에는 모든 위젯이 공유하는 하나의 QStyle 객체가 있기 때문에), QStylePainter는 위젯으로 초기화되므로 모든 함수 호출에 대해 QWidget, QPainter, QStyle 을 지정할 필요가 없습니다.
QStyle 직접 사용 예시:
void MyWidget::paintEvent(QPaintEvent * /* event */) { QPainter painter(this); QStyleOptionFocusRect option; option.initFrom(this); option.backgroundColor = palette().color(QPalette::Background); style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this); }
QStylePainter를 사용하는 예제:
void MyWidget::paintEvent(QPaintEvent * /* event */) { QStylePainter painter(this); QStyleOptionFocusRect option; option.initFrom(this); option.backgroundColor = palette().color(QPalette::Background); painter.drawPrimitive(QStyle::PE_FrameFocusRect, option); }
QStyle 및 QStyleOption 을참조하세요 .
멤버 함수 문서
QStylePainter::QStylePainter()
Q스타일페인터를 생성합니다.
[explicit]
QStylePainter::QStylePainter(QWidget *widget)
페인트 장치에 위젯 widget 을 사용하여 QStylePainter를 구성합니다.
QStylePainter::QStylePainter(QPaintDevice *pd, QWidget *widget)
페인트 장치에 pd 를 사용하고 widget 의 속성을 사용하여 QStylePainter를 구성합니다.
bool QStylePainter::begin(QWidget *widget)
지정된 widget 에서 페인팅 작업을 시작합니다. 페인터를 사용할 준비가 되면 true
을 반환하고, 그렇지 않으면 false
을 반환합니다.
이 함수는 QWidget 을 받는 생성자에 의해 자동으로 호출됩니다.
bool QStylePainter::begin(QPaintDevice *pd, QWidget *widget)
과부하가 걸린 기능입니다.
페인트 장치 pd 에서 마치 widget 인 것처럼 페인팅 작업을 시작합니다.
이 함수는 QPaintDevice 와 QWidget 를 받는 생성자에 의해 자동으로 호출됩니다.
void QStylePainter::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &option)
위젯의 스타일을 사용하여 QStyleOptionComplex option 에 지정된 복잡한 컨트롤 cc 을 그립니다.
QStyle::drawComplexControl()도 참조하세요 .
void QStylePainter::drawControl(QStyle::ControlElement ce, const QStyleOption &option)
위젯의 스타일을 사용하여 QStyleOption option 에 지정된 제어 요소 ce 를 그립니다.
QStyle::drawControl()도 참조하세요 .
void QStylePainter::drawItemPixmap(const QRect &rect, int flags, const QPixmap &pixmap)
직사각형 rect 에 pixmap 을 그립니다. 픽셀맵은 flags 에 따라 정렬됩니다.
QStyle::drawItemPixmap() 및 Qt::Alignment 을참조하세요 .
void QStylePainter::drawItemText(const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole)
직사각형 rect 과 팔레트 pal 에 text 을 그립니다. 텍스트는 flags 에 따라 정렬되고 줄 바꿈됩니다.
펜 색은 textRole 로 지정됩니다. enabled 부울은 항목이 활성화되어 있는지 여부를 나타내며, 이 부울을 다시 구현할 때 항목이 그려지는 방식에 영향을 미칩니다.
QStyle::drawItemText() 및 Qt::Alignment 을참조하세요 .
void QStylePainter::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &option)
위젯의 스타일을 사용하여 QStyleOption option 에 지정된 기본 요소 pe 를 그립니다.
QStyle::drawPrimitive()도 참조하세요 .
QStyle *QStylePainter::style() const
QStylePainter 에서 사용하는 현재 스타일을 반환합니다.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.