qfont.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 870 行 · 第 1/4 页

HTML
870
字号
<p> <p>See also <a href="qapplication.html#setFont">QApplication::setFont</a>() and <a href="qapplication.html#font">QApplication::font</a>().<h3 class=fn><a name="QFont-2"></a>QFont::QFont ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;family, int&nbsp;pointSize = 12, int&nbsp;weight = Normal, bool&nbsp;italic = FALSE )</h3>Constructs a font object with the specified <em>family</em>, <em>pointSize</em>, <em>weight</em> and <em>italic</em> settings.<p> If <em>pointSize</em> is <= 0 it is set to 1.<p> The <em>family</em> name may optionally also include a foundry name,e.g. "Helvetica [Cronyx]". (The Qt 2.x syntax, i.e."Cronyx-Helvetica", is also supported.) If the <em>family</em> isavailable from more than one foundry and the foundry isn'tspecified, an arbitrary foundry is chosen. If the family isn'tavailable a family will be set using the <a href="#fontmatching">font    matching</a> algorithm.<p> <p>See also <a href="#Weight-enum">Weight</a>, <a href="#setFamily">setFamily</a>(), <a href="#setPointSize">setPointSize</a>(), <a href="#setWeight">setWeight</a>(), <a href="#setItalic">setItalic</a>(), <a href="#setStyleHint">setStyleHint</a>() and <a href="qapplication.html#font">QApplication::font</a>().<h3 class=fn><a name="QFont-3"></a>QFont::QFont ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;font )</h3>Constructs a font that is a copy of <em>font</em>.<h3 class=fn><a name="~QFont"></a>QFont::~QFont ()</h3>Destroys the font object and frees all allocated resources.<h3 class=fn>bool <a name="bold"></a>QFont::bold () const</h3><p> Returns TRUE if <a href="#weight">weight</a>() is a value greater than <a href="#Weight-enum">QFont::Normal</a>; otherwise returns FALSE.<p> <p>See also <a href="#weight">weight</a>(), <a href="#setBold">setBold</a>() and <a href="qfontinfo.html#bold">QFontInfo::bold</a>().<p>Example: <a href="tutorial2-09.html#x2539">chart/optionsform.cpp</a>.<h3 class=fn>int <a name="deciPointSize"></a>QFont::deciPointSize () const<tt> [protected]</tt></h3>Returns the point size in 1/10ths of a point.<p> The returned value will be -1 if the font size has been specifiedin pixels.<p> <p>See also <a href="#pointSize">pointSize</a>() and <a href="#pointSizeFloat">pointSizeFloat</a>().<h3 class=fn><a href="qstring.html">QString</a> <a name="defaultFamily"></a>QFont::defaultFamily () const</h3>Returns the family name that corresponds to the current stylehint.<p> <p>See also <a href="#StyleHint-enum">StyleHint</a>, <a href="#styleHint">styleHint</a>() and <a href="#setStyleHint">setStyleHint</a>().<h3 class=fn><a href="qfont.html">QFont</a> <a name="defaultFont"></a>QFont::defaultFont ()<tt> [static]</tt></h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.<p> Please use <a href="qapplication.html#font">QApplication::font</a>() instead.<h3 class=fn>bool <a name="dirty"></a>QFont::dirty () const<tt> [protected]</tt></h3>Returns TRUE if the font attributes have been changed and the fonthas to be (re)loaded; otherwise returns FALSE.<h3 class=fn>bool <a name="exactMatch"></a>QFont::exactMatch () const</h3>Returns TRUE if a window system font exactly matching the settingsof this font is available.<p> <p>See also <a href="qfontinfo.html">QFontInfo</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="family"></a>QFont::family () const</h3>Returns the requested font family name, i.e. the name set in theconstructor or the last setFont() call.<p> <p>See also <a href="#setFamily">setFamily</a>(), <a href="#substitutes">substitutes</a>() and <a href="#substitute">substitute</a>().<p>Examples: <a href="tutorial2-09.html#x2540">chart/optionsform.cpp</a> and <a href="simple-qfont-demo-walkthrough.html#x2110">fonts/simple-qfont-demo/viewer.cpp</a>.<h3 class=fn>bool <a name="fixedPitch"></a>QFont::fixedPitch () const</h3>Returns TRUE if fixed pitch has been set; otherwise returns FALSE.<p> <p>See also <a href="#setFixedPitch">setFixedPitch</a>() and <a href="qfontinfo.html#fixedPitch">QFontInfo::fixedPitch</a>().<h3 class=fn>bool <a name="fromString"></a>QFont::fromString ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;descrip )</h3>Sets this font to match the description <em>descrip</em>. The descriptionis a comma-separated list of the font attributes, as returned by<a href="#toString">toString</a>().<p> <p>See also <a href="#toString">toString</a>() and <a href="#operator-gt-gt">operator&gt;&gt;</a>().<h3 class=fn>HFONT <a name="handle"></a>QFont::handle () const</h3>Returns the window system handle to the font, for low-levelaccess. Using this function is <em>not</em> portable.<h3 class=fn>void <a name="insertSubstitution"></a>QFont::insertSubstitution ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;familyName, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;substituteName )<tt> [static]</tt></h3>Inserts the family name <em>substituteName</em> into the substitutiontable for <em>familyName</em>.<p> <p>See also <a href="#insertSubstitutions">insertSubstitutions</a>(), <a href="#removeSubstitution">removeSubstitution</a>(), <a href="#substitutions">substitutions</a>(), <a href="#substitute">substitute</a>() and <a href="#substitutes">substitutes</a>().<p>Example: <a href="simple-qfont-demo-walkthrough.html#x2111">fonts/simple-qfont-demo/viewer.cpp</a>.<h3 class=fn>void <a name="insertSubstitutions"></a>QFont::insertSubstitutions ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;familyName, const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;substituteNames )<tt> [static]</tt></h3>Inserts the list of families <em>substituteNames</em> into thesubstitution list for <em>familyName</em>.<p> <p>See also <a href="#insertSubstitution">insertSubstitution</a>(), <a href="#removeSubstitution">removeSubstitution</a>(), <a href="#substitutions">substitutions</a>() and <a href="#substitute">substitute</a>().<p>Example: <a href="simple-qfont-demo-walkthrough.html#x2112">fonts/simple-qfont-demo/viewer.cpp</a>.<h3 class=fn>bool <a name="isCopyOf"></a>QFont::isCopyOf ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;f ) const</h3><p> Returns TRUE if this font and <em>f</em> are copies of each other, i.e.one of them was created as a copy of the other and neither hasbeen modified since. This is much stricter than equality.<p> <p>See also <a href="#operator-eq">operator=</a>() and <a href="#operator-eq-eq">operator==</a>().<h3 class=fn>bool <a name="italic"></a>QFont::italic () const</h3>Returns TRUE if italic has been set; otherwise returns FALSE.<p> <p>See also <a href="#setItalic">setItalic</a>().<p>Example: <a href="tutorial2-09.html#x2541">chart/optionsform.cpp</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="key"></a>QFont::key () const</h3>Returns the font's key, a textual representation of a font. It istypically used as the key for a cache or dictionary of fonts.<p> <p>See also <a href="qmap.html">QMap</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="lastResortFamily"></a>QFont::lastResortFamily () const</h3>Returns the "last resort" font family name.<p> The current implementation tries a wide variety of common fonts,returning the first one it finds. Is is possible that no family isfound in which case a null string is returned.<p> <p>See also <a href="#lastResortFont">lastResortFont</a>().<h3 class=fn><a href="qstring.html">QString</a> <a name="lastResortFont"></a>QFont::lastResortFont () const</h3>Returns a "last resort" font name for the font matching algorithm.This is used if the last resort family is not available. It willalways return a name, if necessary returning something like"fixed" or "system".<p> The current implementation tries a wide variety of common fonts,returning the first one it finds. The implementation may changeat any time, but this function will always return a stringcontaining something.<p> It is theoretically possible that there really isn't a<a href="#lastResortFont">lastResortFont</a>() in which case Qt will abort with an errormessage. We have not been able to identify a case where thishappens. Please <a href="bughowto.html">report it as a bug</a> ifit does, preferably with a list of the fonts you have installed.<p> <p>See also <a href="#lastResortFamily">lastResortFamily</a>() and <a href="#rawName">rawName</a>().<h3 class=fn>bool <a name="operator!-eq"></a>QFont::operator!= ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;f ) const</h3>Returns TRUE if this font is different from <em>f</em>; otherwisereturns FALSE.<p> Two QFonts are considered to be different if their font attributesare different. If <a href="#rawMode">rawMode</a>() is enabled for both fonts, only thefamily fields are compared.<p> <p>See also <a href="#operator-eq-eq">operator==</a>().<h3 class=fn><a href="qfont.html">QFont</a>&nbsp;&amp; <a name="operator-eq"></a>QFont::operator= ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;font )</h3>Assigns <em>font</em> to this font and returns a reference to it.<h3 class=fn>bool <a name="operator-eq-eq"></a>QFont::operator== ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;f ) const</h3>Returns TRUE if this font is equal to <em>f</em>; otherwise returnsFALSE.<p> Two QFonts are considered equal if their font attributes areequal. If <a href="#rawMode">rawMode</a>() is enabled for both fonts, only the familyfields are compared.<p> <p>See also <a href="#operator!-eq">operator!=</a>() and <a href="#isCopyOf">isCopyOf</a>().<h3 class=fn>int <a name="pixelSize"></a>QFont::pixelSize () const</h3>Returns the pixel size of the font if it was set with<a href="#setPixelSize">setPixelSize</a>(). Returns -1 if the size was set with <a href="#setPointSize">setPointSize</a>()or <a href="#setPointSizeFloat">setPointSizeFloat</a>().<p> <p>See also <a href="#setPixelSize">setPixelSize</a>(), <a href="#pointSize">pointSize</a>(), <a href="qfontinfo.html#pointSize">QFontInfo::pointSize</a>() and <a href="qfontinfo.html#pixelSize">QFontInfo::pixelSize</a>().<h3 class=fn>int <a name="pointSize"></a>QFont::pointSize () const</h3>Returns the point size of the font. Returns -1 if the font sizewas specified in pixels.<p> <p>See also <a href="#setPointSize">setPointSize</a>(), <a href="#deciPointSize">deciPointSize</a>() and <a href="#pointSizeFloat">pointSizeFloat</a>().<p>Examples: <a href="tutorial2-09.html#x2542">chart/optionsform.cpp</a> and <a href="simple-qfont-demo-walkthrough.html#x2113">fonts/simple-qfont-demo/viewer.cpp</a>.<h3 class=fn>float <a name="pointSizeFloat"></a>QFont::pointSizeFloat () const</h3>Returns the point size of the font. Returns -1 if the font size wasspecified in pixels.<p> <p>See also <a href="#pointSize">pointSize</a>(), <a href="#setPointSizeFloat">setPointSizeFloat</a>(), <a href="#pixelSize">pixelSize</a>(), <a href="qfontinfo.html#pointSize">QFontInfo::pointSize</a>() and <a href="qfontinfo.html#pixelSize">QFontInfo::pixelSize</a>().<h3 class=fn>void <a name="qwsRenderToDisk"></a>QFont::qwsRenderToDisk ( bool&nbsp;all = TRUE )</h3>Saves the glyphs in the font that have previously been accessed asa QPF file. If <em>all</em> is TRUE (the default), then before saving,all glyphs are marked as used.<p> If the font is large and you are sure that only a subset ofcharacters will ever be required on the target device, passingFALSE for the <em>all</em> parameter can save a significant amount ofdisk space.<p> Note that this function is only applicable on Qt/Embedded.<h3 class=fn>bool <a name="rawMode"></a>QFont::rawMode () const</h3>Returns TRUE if raw mode is used for font name matching; otherwisereturns FALSE.<p> <p>See also <a href="#setRawMode">setRawMode</a>() and <a href="#rawName">rawName</a>().<h3 class=fn><a href="qstring.html">QString</a> <a name="rawName"></a>QFont::rawName () const</h3>Returns the name of the font within the underlying window system.On Windows, this is usually just the family name of a TrueTypefont. Under X, it is an XLFD (X Logical Font Description). Usingthe return value of this function is usually <em>not</em> <em>portable</em>.<p> <p>See also <a href="#setRawName">setRawName</a>().<h3 class=fn>void <a name="removeSubstitution"></a>QFont::removeSubstitution ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;familyName )<tt> [static]</tt></h3>Removes all the substitutions for <em>familyName</em>.<p> <p>See also <a href="#insertSubstitutions">insertSubstitutions</a>(), <a href="#insertSubstitution">insertSubstitution</a>(), <a href="#substitutions">substitutions</a>() and <a href="#substitute">substitute</a>().<h3 class=fn>void <a name="setBold"></a>QFont::setBold ( bool&nbsp;enable )</h3><p> If <em>enable</em> is true sets the font's weight to <a href="#Weight-enum">QFont::Bold</a>; otherwise sets the weight to <a href="#Weight-enum">QFont::Normal</a>.<p> For finer boldness control use <a href="#setWeight">setWeight</a>().<p> <p>See also <a href="#bold">bold</a>() and <a href="#setWeight">setWeight</a>().

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?