<qdrawutil.h> - Drawing Utility Functions
| Header: | #include <qdrawutil.h> |
功能
| void | qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap) |
| void | qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules = QTileRules()) |
| void | qDrawPlainRect(QPainter *painter, int x, int y, int width, int height, const QColor &lineColor, int lineWidth = 1, const QBrush *fill = nullptr) |
| void | qDrawPlainRect(QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth = 1, const QBrush *fill = nullptr) |
(since 6.7) void | qDrawPlainRoundedRect(QPainter *painter, int x, int y, int width, int height, qreal rx, qreal ry, const QColor &lineColor, int lineWidth = 1, const QBrush *fill = nullptr) |
(since 6.7) void | qDrawPlainRoundedRect(QPainter *painter, const QRect &rect, qreal rx, qreal ry, const QColor &lineColor, int lineWidth = 1, const QBrush *fill = nullptr) |
| void | qDrawShadeLine(QPainter *painter, int x1, int y1, int x2, int y2, const QPalette &palette, bool sunken = true, int lineWidth = 1, int midLineWidth = 0) |
| void | qDrawShadeLine(QPainter *painter, const QPoint &p1, const QPoint &p2, const QPalette &palette, bool sunken = true, int lineWidth = 1, int midLineWidth = 0) |
| void | qDrawShadePanel(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken = false, int lineWidth = 1, const QBrush *fill = nullptr) |
| void | qDrawShadePanel(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken = false, int lineWidth = 1, const QBrush *fill = nullptr) |
| void | qDrawShadeRect(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken = false, int lineWidth = 1, int midLineWidth = 0, const QBrush *fill = nullptr) |
| void | qDrawShadeRect(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken = false, int lineWidth = 1, int midLineWidth = 0, const QBrush *fill = nullptr) |
| void | qDrawWinButton(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken = false, const QBrush *fill = nullptr) |
| void | qDrawWinButton(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken = false, const QBrush *fill = nullptr) |
| void | qDrawWinPanel(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken = false, const QBrush *fill = nullptr) |
| void | qDrawWinPanel(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken = false, const QBrush *fill = nullptr) |
另请参阅 QPainter 。
函数文档
void qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap)
qDrawBorderPixmap 函数用于将像素图绘制到矩形的边框上。
使用给定的painter ,将给定的pixmap 绘制到给定的target 矩形中。该位图将被划分为九个段,并根据margins 结构进行绘制。
void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules = QTileRules())
使用给定的painter ,将指定sourceRect 矩形从给定的pixmap 绘制到给定的targetRect 矩形中。像素图将根据给定的targetMargins 和sourceMargins 结构被划分为九个片段。最后,像素图将根据给定的rules 进行绘制。
该函数用于绘制缩放后的像素图,类似于CSS3 的 border-images属性
另请参阅 Qt::TileRule 、QTileRules 以及QMargins 。
void qDrawPlainRect(QPainter *painter, int x, int y, int width, int height, const QColor &lineColor, int lineWidth = 1, const QBrush *fill = nullptr)
绘制一个以 (x,y) 为起点的普通矩形,使用给定的width 和height ,并采用指定的painter 、lineColor 和lineWidth 。除非fill 为nullptr ,否则矩形内部将使用fill 画笔填充。
警告:此 函数不会参考QWidget::style() 或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用QFrame 控件,并调用QFrame::setFrameStyle() 函数来显示一个普通矩形:
另请参阅 qDrawShadeRect() 和QStyle 。
void qDrawPlainRect(QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth = 1, const QBrush *fill = nullptr)
使用给定的painter 、lineColor 和lineWidth ,绘制由rect 指定的普通矩形。除非fill 为nullptr ,否则矩形内部将使用fill 画笔填充。
警告:此 函数不会参考QWidget::style() 或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用QFrame 控件,并调用QFrame::setFrameStyle() 函数来显示一个普通矩形:
这是一个重载函数。
另请参阅 qDrawShadeRect() 和QStyle 。
[since 6.7] void qDrawPlainRoundedRect(QPainter *painter, int x, int y, int width, int height, qreal rx, qreal ry, const QColor &lineColor, int lineWidth = 1, const QBrush *fill = nullptr)
绘制一个从 (x,y) 开始的普通圆角矩形,使用给定的width 和height ,水平半径rx 和垂直半径ry ,以及指定的painter 、lineColor 和lineWidth 。除非fill 为nullptr ,否则矩形内部将使用fill 画笔填充。
警告:此 函数不会参考QWidget::style() 或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用QFrame 控件,并调用QFrame::setFrameStyle() 函数来显示一个普通矩形:
该函数在 Qt 6.7 中引入。
另请参阅 qDrawShadeRect() 和QStyle 。
[since 6.7] void qDrawPlainRoundedRect(QPainter *painter, const QRect &rect, qreal rx, qreal ry, const QColor &lineColor, int lineWidth = 1, const QBrush *fill = nullptr)
使用水平半径rx 和垂直半径ry ,以及给定的painter 、lineColor 和lineWidth ,绘制由rect 指定的普通矩形。除非fill 为nullptr ,否则矩形内部将使用fill 画笔填充。
警告:此 函数不会参考QWidget::style() 或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用QFrame 小部件,并调用QFrame::setFrameStyle() 函数来显示一个普通的矩形:
这是一个重载函数。
该函数在 Qt 6.7 中引入。
另请参阅 qDrawShadeRect() 和QStyle 。
void qDrawShadeLine(QPainter *painter, int x1, int y1, int x2, int y2, const QPalette &palette, bool sunken = true, int lineWidth = 1, int midLineWidth = 0)
使用给定的painter 绘制一条水平(y1 ==y2 )或垂直(x1 ==x2 )的阴影线。请注意,如果y1!=y2 且x1!=x2 (即该线既非水平也非垂直),则不会绘制任何内容。
提供的palette 指定了阴影颜色(light 、dark 和middle 颜色)。给定的lineWidth 指定了每条线的线宽;这并非总线宽。给定的midLineWidth 指定了以QPalette::mid()颜色绘制的中央线的宽度。
若sunken 为真,则线条呈现凹陷效果;否则为凸起效果。
警告:此 函数不会参考QWidget::style() 或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用QFrame 控件,并调用QFrame::setFrameStyle() 函数来显示一条带阴影的线:
另请参阅 qDrawShadeRect()、qDrawShadePanel() 以及QStyle 。
void qDrawShadeLine(QPainter *painter, const QPoint &p1, const QPoint &p2, const QPalette &palette, bool sunken = true, int lineWidth = 1, int midLineWidth = 0)
使用给定的painter ,在p1 和p2 之间绘制一条水平或垂直的阴影线。请注意,如果两点之间的连线既非水平也非垂直,则不会绘制任何内容。
提供的palette 指定了阴影颜色(light 、dark 和middle 的颜色)。给定的lineWidth 指定了每条线的线宽;这并非总线宽。给定的midLineWidth 指定了以QPalette::mid()颜色绘制的中间线的宽度。
若sunken 为真,则线条呈现凹陷效果;否则为凸起效果。
警告:此 函数不会参考QWidget::style() 或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用一个QFrame 控件,并调用QFrame::setFrameStyle() 函数来显示一条带阴影的线:
这是一个重载函数。
另请参阅 qDrawShadeRect()、qDrawShadePanel() 以及QStyle 。
void qDrawShadePanel(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken = false, int lineWidth = 1, const QBrush *fill = nullptr)
使用提供的painter 和lineWidth ,绘制从(x,y)开始的带阴影面板,并应用给定的width 和height 。
给定的palette 指定了阴影颜色(light 、dark 和middle 的颜色)。除非fill 的值为nullptr ,否则面板内部将使用fill 画笔填充。
若sunken 为 true,面板将呈现凹陷效果;否则为凸起效果。
警告:此 函数不会参考QWidget::style()或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前GUI样式的控件。
或者,您可以使用QFrame 控件并调用QFrame::setFrameStyle() 函数来显示一个带阴影的面板:
另请参阅 qDrawWinPanel()、qDrawShadeLine()、qDrawShadeRect() 以及QStyle 。
void qDrawShadePanel(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken = false, int lineWidth = 1, const QBrush *fill = nullptr)
使用给定的painter 和lineWidth ,在由rect 指定的矩形内绘制带阴影的面板。
给定的palette 指定了阴影颜色(light 、dark 和middle 颜色)。除非fill 为nullptr ,否则面板内部将使用fill 画笔填充。
若sunken 为 true,面板将呈现凹陷效果;否则为凸起效果。
警告:此 函数不会参考QWidget::style()或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前GUI样式的控件。
或者,您可以使用QFrame 控件,并调用QFrame::setFrameStyle() 函数来显示带阴影的面板:
这是一个重载函数。
另请参阅 qDrawWinPanel()、qDrawShadeLine()、qDrawShadeRect() 以及QStyle 。
void qDrawShadeRect(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken = false, int lineWidth = 1, int midLineWidth = 0, const QBrush *fill = nullptr)
使用提供的painter ,绘制从(x,y)开始、具有给定width 和height 的带阴影矩形。
提供的palette 指定了阴影颜色(light 、dark 和middle )。给定的lineWidth 指定了每条线的线宽;它并非总线宽。midLineWidth 指定了以QPalette::mid()颜色绘制的中间线的宽度。矩形内部将使用fill 画笔填充,除非fill 为nullptr 。
若sunken 为true,则矩形显示为凹陷;否则显示为凸起。
警告:此 函数不会参考QWidget::style() 或QApplication::style() 的值。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用QFrame 控件,并调用QFrame::setFrameStyle() 函数来显示一个带阴影的矩形:
另请参阅 qDrawShadeLine()、qDrawShadePanel()、qDrawPlainRect() 以及QStyle 。
void qDrawShadeRect(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken = false, int lineWidth = 1, int midLineWidth = 0, const QBrush *fill = nullptr)
使用给定的painter ,绘制由rect 指定的带阴影矩形。
提供的palette 指定了阴影颜色(light 、dark 和middle 颜色)。给定的lineWidth 指定了每条线的线宽;它并非总线宽。midLineWidth 指定了用QPalette::mid()颜色绘制的中心线的宽度。矩形内部将用fill 画笔填充,除非fill 为nullptr 。
若sunken 为真,矩形将呈现凹陷效果;否则为凸起效果。
警告:此 函数不会参考QWidget::style()或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前GUI样式的控件。
或者,您可以使用QFrame 控件,并调用QFrame::setFrameStyle() 函数来显示一个带阴影的矩形:
这是一个重载函数。
另请参阅 qDrawShadeLine()、qDrawShadePanel()、qDrawPlainRect() 以及QStyle 。
void qDrawWinButton(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken = false, const QBrush *fill = nullptr)
使用提供的painter (线宽为2像素)绘制由给定点(x ,y},width 和height )指定的Windows风格按钮。除非fill 的值为nullptr ,否则按钮内部将使用fill 画笔填充。
给定的palette 指定了阴影颜色(light 、dark 和middle 颜色)。
若sunken 为 true,则按钮显示为凹陷状态;否则显示为凸起状态。
警告:此 函数不会参考QWidget::style() 或QApplication::style() —— 请使用QStyle 中的绘制函数来制作符合当前 GUI 样式的控件。
另请参阅 qDrawWinPanel() 和QStyle 。
void qDrawWinButton(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken = false, const QBrush *fill = nullptr)
使用给定的painter (线宽为2像素),在rect 指定的矩形内绘制Windows风格的按钮。除非fill 的值为nullptr ,否则按钮内部将使用fill 画笔填充。
给定的palette 指定了阴影颜色(light 、dark 和middle 颜色)。
若sunken 为 true,则按钮显示为凹陷状态;否则显示为凸起状态。
警告:此 函数不会参考QWidget::style() 或QApplication::style() —— 请使用QStyle 中的绘图函数来制作符合当前 GUI 样式的控件。
这是一个重载函数。
另请参阅 qDrawWinPanel() 和QStyle 。
void qDrawWinPanel(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken = false, const QBrush *fill = nullptr)
使用提供的painter (线宽为2像素)绘制由给定点(x,y)、width 和height 指定的Windows风格面板。按钮内部将使用fill 画笔填充,除非fill 的值为nullptr 。
给定的palette 指定了阴影颜色。若sunken 为true,则面板呈现凹陷效果;否则呈现凸起效果。
警告:此 函数不会参考QWidget::style() 或QApplication::style()。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用QFrame 小部件,并应用QFrame::setFrameStyle() 函数来显示一个带阴影的面板:
另请参阅 qDrawShadePanel()、qDrawWinButton() 以及QStyle 。
void qDrawWinPanel(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken = false, const QBrush *fill = nullptr)
使用给定的painter (线宽为2像素),在rect 指定的矩形区域内绘制Windows风格的面板。按钮内部将使用fill 画笔填充,除非fill 为nullptr 。
给定的palette 指定了阴影颜色。如果sunken 为true,面板看起来是凹陷的;否则为凸起的。
警告:此 函数不会参考QWidget::style() 或QApplication::style() 的值。请使用QStyle 中的绘图函数来创建符合当前 GUI 样式的控件。
或者,您可以使用QFrame 控件并调用QFrame::setFrameStyle() 函数来显示一个带阴影的面板:
这是一个重载函数。
另请参阅 qDrawShadePanel()、qDrawWinButton() 以及QStyle 。
© 2026 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.