QTextCharFormat Class Reference
[QtGui module]
该QTextCharFormat类提供格式设置信息的字符QTextDocument。More…
继承QTextFormat。
通过继承QTextImageFormat和QTextTableCellFormat。
Types
enum UnderlineStyle { NoUnderline, SingleUnderline, DashUnderline, DotLine, ..., SpellCheckUnderline }
enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript, AlignMiddle, ..., AlignBaseline }
Methods
__init__ (self)
__init__ (self, QTextCharFormat)
QString anchorHref (self)
QString anchorName (self)
QStringList anchorNames (self)
QFont font (self)
QFont.Capitalization fontCapitalization (self)
QString fontFamily (self)
bool fontFixedPitch (self)
QFont.HintingPreference fontHintingPreference (self)
bool fontItalic (self)
bool fontKerning (self)
float fontLetterSpacing (self)
bool fontOverline (self)
float fontPointSize (self)
bool fontStrikeOut (self)
QFont.StyleHint fontStyleHint (self)
QFont.StyleStrategy fontStyleStrategy (self)
bool fontUnderline (self)
int fontWeight (self)
float fontWordSpacing (self)
bool isAnchor (self)
bool isValid (self)
setAnchor (self, bool anchor)
setAnchorHref (self, QString value)
setAnchorName (self, QString name)
setAnchorNames (self, QStringList names)
setFont (self, QFont font)
setFontCapitalization (self, QFont.Capitalization capitalization)
setFontFamily (self, QString family)
setFontFixedPitch (self, bool fixedPitch)
setFontHintingPreference (self, QFont.HintingPreference hintingPreference)
setFontItalic (self, bool italic)
setFontKerning (self, bool enable)
setFontLetterSpacing (self, float spacing)
setFontOverline (self, bool overline)
setFontPointSize (self, float size)
setFontStrikeOut (self, bool strikeOut)
setFontStyleHint (self, QFont.StyleHint hint, QFont.StyleStrategy strategy = QFont.PreferDefault)
setFontStyleStrategy (self, QFont.StyleStrategy strategy)
setFontUnderline (self, bool underline)
setFontWeight (self, int weight)
setFontWordSpacing (self, float spacing)
setTableCellColumnSpan (self, int atableCellColumnSpan)
setTableCellRowSpan (self, int atableCellRowSpan)
setTextOutline (self, QPen pen)
setToolTip (self, QString tip)
setUnderlineColor (self, QColor color)
setUnderlineStyle (self, UnderlineStyle style)
setVerticalAlignment (self, VerticalAlignment alignment)
int tableCellColumnSpan (self)
int tableCellRowSpan (self)
QPen textOutline (self)
QString toolTip (self)
QColor underlineColor (self)
UnderlineStyle underlineStyle (self)
VerticalAlignment verticalAlignment (self)
Detailed Description
该QTextCharFormat类提供格式设置信息的字符QTextDocument。
在文档中的文本的字符格式指定的文本的可视特性,以及关于其在一个超文本文件的作用的信息。
使用的字体可以通过提供一种字体的设置setFont()函数,并且其外观的各个方面可以调整,以得到所需的效果。setFontFamily()和setFontPointSize( )定义字体的家庭(如时间)和印刷尺寸;setFontWeight()和setFontItalic( )提供了对字体的样式控制。setFontUnderline( )setFontOverline( )setFontStrikeOut()和setFontFixedPitch( )为文本附加效果。
颜色设置与setForeground( ) 。如果文本旨在用作锚(超链接) ,这可以被启用setAnchor( ) 。该setAnchorHref()和setAnchorNames()函数用于指定关于超链接的目标与锚的名称的信息。
Type Documentation
QTextCharFormat.UnderlineStyle
这个枚举变量描述了不同的方式绘制下划线的文本。
Constant | Value | Description |
---|---|---|
QTextCharFormat.NoUnderline |
0 |
文字是画,没有任何强调装饰。 |
QTextCharFormat.SingleUnderline |
1 |
A线是用画Qt.SolidLine。 |
QTextCharFormat.DashUnderline |
2 |
破折号使用绘制Qt.DashLine。 |
QTextCharFormat.DotLine |
3 |
点是使用绘制Qt.DotLine; |
QTextCharFormat.DashDotLine |
4 |
Dashs和点使用绘制Qt.DashDotLine。 |
QTextCharFormat.DashDotDotLine |
5 |
强调用画绘制Qt.DashDotDotLine。 |
QTextCharFormat.WaveUnderline |
6 |
该文本是用波浪形下划线标出。 |
QTextCharFormat.SpellCheckUnderline |
7 |
视乎该QStyle.SH_SpellCeckUnderlineStyle风格提示下划线绘制QApplication风格。默认情况下,这个被映射到WaveUnderline ,在Mac OS X被映射到DashDotLine 。 |
See also Qt.PenStyle。
QTextCharFormat.VerticalAlignment
该枚举描述的方式使相邻的字符可以垂直对齐。
Constant | Value | Description |
---|---|---|
QTextCharFormat.AlignNormal |
0 |
相邻字符被放置在标准方式中的写入系统中使用的文本。 |
QTextCharFormat.AlignSuperScript |
1 |
字符放在高于正常文本基线。 |
QTextCharFormat.AlignSubScript |
2 |
字符都放在下面的普通文本基线。 |
QTextCharFormat.AlignMiddle |
3 |
对象的中心垂直基准线对齐。目前,这只是实施了内联对象。 |
QTextCharFormat.AlignBottom |
5 |
物体的底部边缘垂直基准线对齐。 |
QTextCharFormat.AlignTop |
4 |
对象的上边缘垂直的基准线对齐。 |
QTextCharFormat.AlignBaseline |
6 |
字符的基线对齐。 |
Method Documentation
QTextCharFormat.__init__ (self)
构造一个新的字符格式的对象。
QTextCharFormat.__init__ (self, QTextCharFormat)
QString QTextCharFormat.anchorHref (self)
返回如果没有设置文本格式的超文本链接,或空字符串。
See also setAnchorHref( ) 。
QString QTextCharFormat.anchorName (self)
QStringList QTextCharFormat.anchorNames (self)
返回与此文本格式,或者一个空字符串列表相关联,如果没有设置锚的名称。如果锚的名称被设置,文本这种格式可以是一个超文本链接的目标。
此功能被引入Qt的4.3 。
See also setAnchorNames( ) 。
QFont QTextCharFormat.font (self)
[
返回的字体为这个字符格式。
]($docs-qfont.html)
QFont.Capitalization QTextCharFormat.fontCapitalization (self)
[
返回该字体的当前市值类型。
此功能被引入Qt的4.4 。
]($docs-qfont.html#Capitalization-enum)
See also setFontCapitalization( ) 。
QString QTextCharFormat.fontFamily (self)
返回文本格式的字体系列。
See also setFontFamily()和font( ) 。
bool QTextCharFormat.fontFixedPitch (self)
返回True如果文本格式的字体是固定的间距,否则返回False 。
See also setFontFixedPitch()和font( ) 。
QFont.HintingPreference QTextCharFormat.fontHintingPreference (self)
[
返回此文本格式的暗示偏好设定。
此功能被引入Qt的4.8 。
]($docs-qfont.html#HintingPreference-enum)
See also setFontHintingPreference( )font()和QFont.hintingPreference( ) 。
bool QTextCharFormat.fontItalic (self)
返回True如果文本格式的字体是斜体,否则返回False 。
See also setFontItalic()和font( ) 。
bool QTextCharFormat.fontKerning (self)
如果字体启用字距调整,则返回True 。
此功能被引入Qt的4.5 。
See also setFontKerning()和font( ) 。
float QTextCharFormat.fontLetterSpacing (self)
返回当前字母间距百分比。
此功能被引入Qt的4.4 。
See also setFontLetterSpacing( ) 。
bool QTextCharFormat.fontOverline (self)
返回True如果文本格式的字体是上划线,否则返回False 。
See also setFontOverline()和font( ) 。
float QTextCharFormat.fontPointSize (self)
返回用于这种格式显示文本的字体大小。
See also setFontPointSize()和font( ) 。
bool QTextCharFormat.fontStrikeOut (self)
返回True如果文本格式的字体被剔除(有一个水平线通过它绘制的),否则返回False 。
See also setFontStrikeOut()和font( ) 。
QFont.StyleHint QTextCharFormat.fontStyleHint (self)
[
返回的字体样式提示。
此功能被引入Qt的4.5 。
]($docs-qfont.html#StyleHint-enum)
See also setFontStyleHint()和font( ) 。
QFont.StyleStrategy QTextCharFormat.fontStyleStrategy (self)
[
返回当前字体样式的策略。
此功能被引入Qt的4.5 。
]($docs-qfont.html#StyleStrategy-enum)
See also setFontStyleStrategy()和font( ) 。
bool QTextCharFormat.fontUnderline (self)
返回True如果文本格式的字体下划线,否则返回False 。
See also setFontUnderline()和font( ) 。
int QTextCharFormat.fontWeight (self)
返回文本格式的字体粗细。
See also setFontWeight( )font()和QFont.Weight。
float QTextCharFormat.fontWordSpacing (self)
返回当前的字间距值。
此功能被引入Qt的4.4 。
See also setFontWordSpacing( ) 。
bool QTextCharFormat.isAnchor (self)
返回True如果文本被格式化为一个锚,否则返回False 。
See also setAnchor( )setAnchorHref()和setAnchorNames( ) 。
bool QTextCharFormat.isValid (self)
返回True如果这个字符格式是有效的,否则返回False 。
QTextCharFormat.setAnchor (self, bool anchor)
If anchor是真的,文字这种格式表示锚,并格式化适当的方式,否则文本通常格式化。 (锚是这往往显示下划线,并以不同的颜色从纯文本的超链接。 )
文本呈现的方式是独立的格式是否有定义的有效支撑点。使用setAnchorHref() ,以及任选setAnchorNames()来创建一个超文本链接。
See also isAnchor( ) 。
QTextCharFormat.setAnchorHref (self, QString value)
设置超文本链接的文本格式,以给定的value。这通常是像“ http://example.com/index.html ”的URL。
锚将与被显示value作为其显示文本,如果你想显示不同的文本调用setAnchorNames( ) 。
格式化文本作为超链接的使用setAnchor( ) 。
See also anchorHref( ) 。
QTextCharFormat.setAnchorName (self, QString name)
QTextCharFormat.setAnchorNames (self, QStringList names)
设置文本格式的锚names。对于锚的工作作为一个超链接时,目标必须与设置setAnchorHref()和所述锚定必须被启用setAnchor( ) 。
此功能被引入Qt的4.3 。
See also anchorNames( ) 。
QTextCharFormat.setFont (self, QFont font)
设置文本格式的font。
See also font( ) 。
QTextCharFormat.setFontCapitalization (self, QFont.Capitalization capitalization)
设置apppears在这种字体的文本的大小写capitalization。
字体的大小写使文本显示在选定资本化模式。
此功能被引入Qt的4.4 。
See also fontCapitalization( ) 。
QTextCharFormat.setFontFamily (self, QString family)
设置文本格式的字体family。
See also fontFamily()和setFont( ) 。
QTextCharFormat.setFontFixedPitch (self, bool fixedPitch)
If fixedPitch诚然,设置文本格式的字体是固定的间距,否则非固定间距字体。
See also fontFixedPitch()和setFont( ) 。
QTextCharFormat.setFontHintingPreference (self, QFont.HintingPreference hintingPreference)
设置文本格式的字体是的暗示偏好hintingPreference。
此功能被引入Qt的4.8 。
See also fontHintingPreference( )setFont()和QFont.setHintingPreference( ) 。
QTextCharFormat.setFontItalic (self, bool italic)
If italic诚然,设置文本格式的字体是斜体,否则字体将非斜体。
See also fontItalic()和setFont( ) 。
QTextCharFormat.setFontKerning (self, bool enable)
启用字距这个字体,如果enable为True,否则禁用它。
如果启用字距调整,字形度量对不上号了,即使是拉丁文字。换句话说,该宽度(’ a’)的宽度+ (’ b’)中的假设是等于宽度( “AB” )是不neccesairly真。
此功能被引入Qt的4.5 。
See also fontKerning()和setFont( ) 。
QTextCharFormat.setFontLetterSpacing (self, float spacing)
设置此格式的字母间距为给定的spacing,以百分比表示。值为100表示默认间距; 200的值加倍的一封信需要的空间量。
此功能被引入Qt的4.4 。
See also fontLetterSpacing( ) 。
QTextCharFormat.setFontOverline (self, bool overline)
If overline诚然,设置文本格式的字体要上划线,否则显示的字体不上划线。
See also fontOverline()和setFont( ) 。
QTextCharFormat.setFontPointSize (self, float size)
设置文本格式的字体size。
See also fontPointSize()和setFont( ) 。
QTextCharFormat.setFontStrikeOut (self, bool strikeOut)
If strikeOut诚然,设置文本格式的字体与剔除启用(有横线穿过它) ,否则将显示不带删除线。
See also fontStrikeOut()和setFont( ) 。
QTextCharFormat.setFontStyleHint (self, QFont.StyleHint hint, QFont.StyleStrategy strategy = QFont.PreferDefault)
设置字体样式hint和strategy。
Qt不支持样式提示在X11 ,因为没有提供窗口系统信息。
此功能被引入Qt的4.5 。
See also fontStyleHint( )setFont()和QFont.setStyleHint( ) 。
QTextCharFormat.setFontStyleStrategy (self, QFont.StyleStrategy strategy)
设置字体样式strategy。
此功能被引入Qt的4.5 。
See also fontStyleStrategy( )setFont()和QFont.setStyleStrategy( ) 。
QTextCharFormat.setFontUnderline (self, bool underline)
If underline诚然,设置文本格式的字体加下划线,否则将显示非下划线。
See also fontUnderline()和setFont( ) 。
QTextCharFormat.setFontWeight (self, int weight)
设置文本格式的字体重量weight。
See also fontWeight( )setFont()和QFont.Weight。
QTextCharFormat.setFontWordSpacing (self, float spacing)
设置此格式的字间距为给定的spacing,以像素为单位。
此功能被引入Qt的4.4 。
See also fontWordSpacing( ) 。
QTextCharFormat.setTableCellColumnSpan (self, int atableCellColumnSpan)
QTextCharFormat.setTableCellRowSpan (self, int atableCellRowSpan)
QTextCharFormat.setTextOutline (self, QPen pen)
设置用于绘制人物的轮廓给定的笔pen。
See also textOutline( ) 。
QTextCharFormat.setToolTip (self, QString tip)
工具提示文本的片段设置为给定text。
此功能被引入Qt的4.3 。
See also toolTip( ) 。
QTextCharFormat.setUnderlineColor (self, QColor color)
设置用于与此格式的字符的下划线颜色color规定。
See also underlineColor( ) 。
QTextCharFormat.setUnderlineStyle (self, UnderlineStyle style)
设置下划线的文本的样式style。
这个函数中引入了Qt 4.2中。
See also underlineStyle( ) 。
QTextCharFormat.setVerticalAlignment (self, VerticalAlignment alignment)
设置用于与此格式的字符的垂直对齐方式alignment规定。
See also verticalAlignment( ) 。
int QTextCharFormat.tableCellColumnSpan (self)
int QTextCharFormat.tableCellRowSpan (self)
QPen QTextCharFormat.textOutline (self)
[
返回用于绘制人物的轮廓在这种格式的笔。
]($docs-qpen.html)
See also setTextOutline( ) 。
QString QTextCharFormat.toolTip (self)
返回显示的文本片段的工具提示。
此功能被引入Qt的4.3 。
See also setToolTip( ) 。
QColor QTextCharFormat.underlineColor (self)
[
返回用于强调这种格式的字符的颜色。
]($docs-qcolor.html)
See also setUnderlineColor( ) 。
UnderlineStyle QTextCharFormat.underlineStyle (self)
[
返回强调文本的样式。
这个函数中引入了Qt 4.2中。
]($docs-qtextcharformat.html#UnderlineStyle-enum)
See also setUnderlineStyle( ) 。
VerticalAlignment QTextCharFormat.verticalAlignment (self)
[
返回用于与此格式字符的垂直对齐方式。
]($docs-qtextcharformat.html#VerticalAlignment-enum)