QPainterPathStroker 類

QPainterPathStroker 類用於為給定描繪器路徑生成可填充輪廓。 更多...

頭: #include <QPainterPathStroker>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

公共函數

QPainterPathStroker ()
QPainterPathStroker (const QPen & pen )
~QPainterPathStroker ()
Qt::PenCapStyle capStyle () const
QPainterPath createStroke (const QPainterPath & path ) const
qreal curveThreshold () const
qreal dashOffset () const
QList<qreal> dashPattern () const
Qt::PenJoinStyle joinStyle () const
qreal miterLimit () const
void setCapStyle (Qt::PenCapStyle style )
void setCurveThreshold (qreal threshold )
void setDashOffset (qreal offset )
void setDashPattern (Qt::PenStyle style )
void setDashPattern (const QList<qreal> & dashPattern )
void setJoinStyle (Qt::PenJoinStyle style )
void setMiterLimit (qreal limit )
void setWidth (qreal width )
qreal width () const

詳細描述

通過調用 createStroke () 函數,傳遞給定 QPainterPath 作為自變量,創建錶示給定路徑輪廓的新描繪器路徑。然後可以填充新近創建的描繪器路徑以繪製原始描繪器路徑的輪廓。

可以使用下列函數,控製輪廓描繪的各設計方麵 (寬度、帽樣式、聯接樣式及虛綫模式):

The setDashPattern () 函數接受 Qt::PenStyle object and a list representation of the pattern as argument.

此外,可以指定麯綫的閾值,控製麯綫繪製的粒度,使用 setCurveThreshold () 函數。默認閾值的良好調節值是 0.25,且通常應該不需要修改。不管怎樣,通過遞減其值可以使麯綫外觀更平滑。

還可以控製生成輪廓的斜接限製使用 setMiterLimit () 函數。斜接限製描述斜接聯接,可以從每聯接延伸多遠。限製以寬度單位指定,所以,像素級斜接限製將為 miterlimit * width 。纔使用此值,若聯接樣式為 Qt::MiterJoin .

描繪器路徑的生成通過 createStroke () 函數隻應用於輪廓描繪給定描繪器路徑。否則可能導緻意外行為。生成的輪廓還要求 Qt::WindingFill 規則 (這是默認設置)。

另請參閱 QPen and QBrush .

成員函數文檔編製

QPainterPathStroker:: QPainterPathStroker ()

創建新的描邊器。

[explicit] QPainterPathStroker:: QPainterPathStroker (const QPen & pen )

創建新的描邊器基於 pen .

QPainterPathStroker:: ~QPainterPathStroker ()

銷毀描邊器。

Qt::PenCapStyle QPainterPathStroker:: capStyle () const

返迴生成輪廓的帽樣式。

另請參閱 setCapStyle ().

QPainterPath QPainterPathStroker:: createStroke (const QPainterPath & path ) const

生成是可填充區域的新路徑錶示輪廓為給定 path .

輪廓的各設計方麵是基於描邊器特性: width (), capStyle (), joinStyle (), dashPattern (), curveThreshold () 和 miterLimit ().

生成路徑隻應用於輪廓化給定描繪器路徑。否則,可能導緻意外行為。生成輪廓還要求 Qt::WindingFill 規則 (這是默認設置)。

qreal QPainterPathStroker:: curveThreshold () const

返迴生成輪廓的麯綫扁平化閾值。

另請參閱 setCurveThreshold ().

qreal QPainterPathStroker:: dashOffset () const

返迴生成輪廓的虛綫偏移。

另請參閱 setDashOffset ().

QList < qreal > QPainterPathStroker:: dashPattern () const

返迴生成輪廓的虛綫模式。

另請參閱 setDashPattern ().

Qt::PenJoinStyle QPainterPathStroker:: joinStyle () const

返迴生成輪廓的聯接樣式。

另請參閱 setJoinStyle ().

qreal QPainterPathStroker:: miterLimit () const

返迴生成輪廓的斜接限製。

另請參閱 setMiterLimit ().

void QPainterPathStroker:: setCapStyle ( Qt::PenCapStyle style )

將生成輪廓的帽樣式設為 style 。若虛綫模式有設置,則模式每段服從帽 style .

另請參閱 capStyle ().

void QPainterPathStroker:: setCurveThreshold ( qreal threshold )

指定麯綫扁平化 threshold ,控製繪製生成輪廓麯綫的粒度。

默認閾值的良好調節值是 0.25,且通常應該不需要修改。不管怎樣,通過遞減其值可以使麯綫外觀更平滑。

另請參閱 curveThreshold ().

void QPainterPathStroker:: setDashOffset ( qreal offset )

將生成輪廓的虛綫偏移設為 offset .

見文檔編製為 QPen::setDashOffset () 瞭解虛綫偏移的描述。

另請參閱 dashOffset ().

void QPainterPathStroker:: setDashPattern ( Qt::PenStyle style )

將生成輪廓的虛綫圖案設為 style .

另請參閱 dashPattern ().

void QPainterPathStroker:: setDashPattern (const QList < qreal > & dashPattern )

這是重載函數。

將生成輪廓的虛綫圖案設為 dashPattern 。此函數使之可能指定自定義虛綫模式。

Each element in the list contains the lengths of the dashes and spaces in the stroke, beginning with the first dash in the first element, the first space in the second element, and alternating between dashes and spaces for each following pair of elements.

The list can contain an odd number of elements, in which case the last element will be extended by the length of the first element when the pattern repeats.

void QPainterPathStroker:: setJoinStyle ( Qt::PenJoinStyle style )

將生成輪廓的聯接樣式設為 style .

另請參閱 joinStyle ().

void QPainterPathStroker:: setMiterLimit ( qreal limit )

將生成輪廓的斜接限製設為 limit .

斜接限製描述斜接聯接可以從每個聯接延伸多遠。限製以目前設置的寬度為單位指定。所以,像素級斜接限製將為 miterlimit * width .

纔使用此值,若聯接樣式為 Qt::MiterJoin .

另請參閱 miterLimit ().

void QPainterPathStroker:: setWidth ( qreal width )

將生成輪廓描繪器路徑的寬度設為 width .

生成輪廓將延伸約 50% 的 width 到給定輸入路徑原始輪廓的每側。

另請參閱 width ().

qreal QPainterPathStroker:: width () const

返迴生成輪廓的寬度。

另請參閱 setWidth ().