QPainterPathStroker 類

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

頭: #include <QPainterPathStroker>
qmake: QT += gui
Since: Qt 4.1

公共函數

QPainterPathStroker ()
QPainterPathStroker (const QPen & pen )
~QPainterPathStroker ()
Qt::PenCapStyle capStyle () const
QPainterPath createStroke (const QPainterPath & path ) const
qreal curveThreshold () const
qreal dashOffset () const
QVector<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 QVector<qreal> & dashPattern )
void setJoinStyle (Qt::PenJoinStyle style )
void setMiterLimit (qreal limit )
void setWidth (qreal width )
qreal width () const

詳細描述

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

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

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

The setDashPattern () 函數接受 Qt::PenStyle 對象和模式嚮量錶示作為自變量。

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

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

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

另請參閱 QPen and QBrush .

成員函數文檔編製

QPainterPathStroker:: QPainterPathStroker ()

創建新的描邊器。

QPainterPathStroker:: QPainterPathStroker (const QPen & pen )

創建新的描邊器基於 pen .

該函數在 Qt 5.3 引入。

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 ().

QVector < 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 QVector < qreal > & dashPattern )

這是重載函數。

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

每一嚮量元素包含描邊器虛綫長度和空格,從第一元素的第一虛綫開始,第二元素的第一空格,之後每對元素的虛綫和空格交替。

嚮量可以包含奇數個元素,在這種情況下,最後元素將按第一元素的長度延伸,當圖案重復時。

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 ().