QStylePainter Class
QStylePainter クラスは、ウィジェット内のQStyle 要素を描画するための便利なクラスです。詳細...
ヘッダー | #include <QStylePainter> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
継承: | QPainter |
- 継承メンバを含む全メンバのリスト
- QStylePainterはPainting Classesの一部です。
パブリック関数
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 はQStyle の API の上に実装された高レベルのdraw...()
関数のセットでQPainter を拡張します。QStylePainterを使う利点は、パラメータリストがかなり短くなることです。通常、アプリケーションはすべてのウィジェットで共有される1つの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()
QStylePainter を構築します。
[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)
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)
text を矩形rect とパレットpal に描画します。テ キ ス ト はflags に従っ て整列 さ れ、 回 り 込まれます。
ペンの色はtextRole で指定する。enabled bool は、アイテムが有効かどうかを示します。再実装する場合、この bool はアイテムの描画方法に影響するはずです。
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.