Obsolete Members for QFontMetrics

以下成員源於類 QFontMetrics 已過時。 提供它們是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它們。

公共函數

(obsolete) QFontMetrics (const QFont & font , QPaintDevice * paintdevice )
(obsolete) int charWidth (const QString & text , int pos ) const
(obsolete) int width (QChar ch ) const
(obsolete) int width (const QString & text , int len = -1) const

成員函數文檔編製

QFontMetrics:: QFontMetrics (const QFont & font , QPaintDevice * paintdevice )

此函數已過時。提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。

Identical to QFontMetrics::QFontMetrics (const QFont &font, const QPaintDevice *paintdevice)

int QFontMetrics:: charWidth (const QString & text , int pos ) const

此函數已過時。提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。

Returns the width of the character at position pos in the string text .

The whole string is needed, as the glyph drawn may change depending on the context (the letter before and after the current one) for some languages (e.g. Arabic).

This function also takes non spacing marks and ligatures into account.

int QFontMetrics:: width ( QChar ch ) const

此函數已過時。提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。

這是重載函數。

Bearings

Returns the logical width of character ch 以像素為單位。這是適閤繪製後續字符的距離後於 ch .

Some of the metrics are described in the image to the right. The central dark rectangles cover the logical width() of each character. The outer pale rectangles cover the leftBearing () 和 rightBearing () of each character. Notice that the bearings of "f" in this particular font are both negative, while the bearings of "o" are both positive.

in Qt 5.11. Use horizontalAdvance () 代替。

警告: This function will produce incorrect results for Arabic characters or non-spacing marks in the middle of a string, as the glyph shaping and positioning of marks that happens when processing strings cannot be taken into account. When implementing an interactive text control, use QTextLayout 代替。

另請參閱 boundingRect () 和 horizontalAdvance ().

int QFontMetrics:: width (const QString & text , int len = -1) const

此函數已過時。提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。

(以像素為單位) 返迴寬度對於第一 len 字符的 text 。若 len 為負 (默認),使用整個字符串。

注意,此值為 not 等於 boundingRect ().width(); boundingRect () 返迴此字符串將覆蓋像素的描述矩形,而 width() 返迴應繪製的下一字符串距離。

in Qt 5.11. Use horizontalAdvance () 代替。

另請參閱 boundingRect () 和 horizontalAdvance ().