⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qheader.html

📁 QT参考文档
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/widgets/qheader.cpp:137 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="Translator" content="farfareast"><meta name="Qt zh_CN Documents Website" content="http://www.qiliang.net/qt"><title>QHeader类</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; font-family: "Times New Roman" }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">主页</font></a> | <a href="classes.html"><font color="#004faf">所有的类</font></a> | <a href="mainclasses.html"><font color="#004faf">主要的类</font></a> | <a href="annotated.html"><font color="#004faf">注释的类</font></a> | <a href="groups.html"><font color="#004faf">分组的类</font></a> | <a href="functions.html"><font color="#004faf">函数</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QHeader类参考</h1><p>QHeader类为诸如表格和列表(listview)等提供标题行或者列。<a href="#details">详见……</a><p><tt>#include &lt;<a href="qheader-h.html">qheader.h</a>&gt;</tt><p>继承了<a href="qwidget.html">QWidget</a>。<p><a href="qheader-members.html">所有成员函数的列表。</a><h2>公共成员</h2><ul><li><div class=fn><a href="#QHeader"><b>QHeader</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li><li><div class=fn><a href="#QHeader-2"><b>QHeader</b></a> ( int&nbsp;n, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li><li><div class=fn><a href="#~QHeader"><b>~QHeader</b></a> ()</div></li><li><div class=fn>int <a href="#addLabel"><b>addLabel</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;s, int&nbsp;size = -1 )</div></li><li><div class=fn>int <a href="#addLabel-2"><b>addLabel</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;iconset, const&nbsp;QString&nbsp;&amp;&nbsp;s, int&nbsp;size = -1 )</div></li><li><div class=fn>void <a href="#removeLabel"><b>removeLabel</b></a> ( int&nbsp;section )</div></li><li><div class=fn>virtual void <a href="#setLabel"><b>setLabel</b></a> ( int&nbsp;section, const&nbsp;QString&nbsp;&amp;&nbsp;s, int&nbsp;size = -1 )</div></li><li><div class=fn>virtual void <a href="#setLabel-2"><b>setLabel</b></a> ( int&nbsp;section, const&nbsp;QIconSet&nbsp;&amp;&nbsp;iconset, const&nbsp;QString&nbsp;&amp;&nbsp;s, int&nbsp;size = -1 )</div></li><li><div class=fn>QString <a href="#label"><b>label</b></a> ( int&nbsp;section ) const</div></li><li><div class=fn>QIconSet * <a href="#iconSet"><b>iconSet</b></a> ( int&nbsp;section ) const</div></li><li><div class=fn>virtual void <a href="#setOrientation"><b>setOrientation</b></a> ( Orientation )</div></li><li><div class=fn>Orientation <a href="#orientation"><b>orientation</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setTracking"><b>setTracking</b></a> ( bool&nbsp;enable )</div></li><li><div class=fn>bool <a href="#tracking"><b>tracking</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setClickEnabled"><b>setClickEnabled</b></a> ( bool&nbsp;enable, int&nbsp;section = -1 )</div></li><li><div class=fn>virtual void <a href="#setResizeEnabled"><b>setResizeEnabled</b></a> ( bool&nbsp;enable, int&nbsp;section = -1 )</div></li><li><div class=fn>virtual void <a href="#setMovingEnabled"><b>setMovingEnabled</b></a> ( bool )</div></li><li><div class=fn>virtual void <a href="#setStretchEnabled"><b>setStretchEnabled</b></a> ( bool&nbsp;b, int&nbsp;section )</div></li><li><div class=fn>void <a href="#setStretchEnabled-2"><b>setStretchEnabled</b></a> ( bool&nbsp;b )</div></li><li><div class=fn>bool <a href="#isClickEnabled"><b>isClickEnabled</b></a> ( int&nbsp;section = -1 ) const</div></li><li><div class=fn>bool <a href="#isResizeEnabled"><b>isResizeEnabled</b></a> ( int&nbsp;section = -1 ) const</div></li><li><div class=fn>bool <a href="#isMovingEnabled"><b>isMovingEnabled</b></a> () const</div></li><li><div class=fn>bool <a href="#isStretchEnabled"><b>isStretchEnabled</b></a> () const</div></li><li><div class=fn>bool <a href="#isStretchEnabled-2"><b>isStretchEnabled</b></a> ( int&nbsp;section ) const</div></li><li><div class=fn>void <a href="#resizeSection"><b>resizeSection</b></a> ( int&nbsp;section, int&nbsp;s )</div></li><li><div class=fn>int <a href="#sectionSize"><b>sectionSize</b></a> ( int&nbsp;section ) const</div></li><li><div class=fn>int <a href="#sectionPos"><b>sectionPos</b></a> ( int&nbsp;section ) const</div></li><li><div class=fn>int <a href="#sectionAt"><b>sectionAt</b></a> ( int&nbsp;pos ) const</div></li><li><div class=fn>int <a href="#count"><b>count</b></a> () const</div></li><li><div class=fn>int <a href="#headerWidth"><b>headerWidth</b></a> () const</div></li><li><div class=fn>QRect <a href="#sectionRect"><b>sectionRect</b></a> ( int&nbsp;section ) const</div></li><li><div class=fn>virtual void setCellSize ( int&nbsp;section, int&nbsp;s ) &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>int cellSize ( int&nbsp;i ) const &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>int cellPos ( int&nbsp;i ) const &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>int cellAt ( int&nbsp;pos ) const &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>int <a href="#offset"><b>offset</b></a> () const</div></li><li><div class=fn>int <a href="#mapToSection"><b>mapToSection</b></a> ( int&nbsp;index ) const</div></li><li><div class=fn>int <a href="#mapToIndex"><b>mapToIndex</b></a> ( int&nbsp;section ) const</div></li><li><div class=fn>int mapToLogical ( int&nbsp;a ) const &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>int mapToActual ( int&nbsp;l ) const &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>void <a href="#moveSection"><b>moveSection</b></a> ( int&nbsp;section, int&nbsp;toIndex )</div></li><li><div class=fn>virtual void moveCell ( int&nbsp;fromIdx, int&nbsp;toIdx ) &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>void <a href="#setSortIndicator"><b>setSortIndicator</b></a> ( int&nbsp;section, bool&nbsp;increasing = TRUE )</div></li><li><div class=fn>void <a href="#adjustHeaderSize"><b>adjustHeaderSize</b></a> ()</div></li></ul><h2>公共槽</h2><ul><li><div class=fn>virtual void <a href="#setOffset"><b>setOffset</b></a> ( int&nbsp;pos )</div></li></ul><h2>信号</h2><ul><li><div class=fn>void <a href="#clicked"><b>clicked</b></a> ( int&nbsp;section )</div></li><li><div class=fn>void <a href="#pressed"><b>pressed</b></a> ( int&nbsp;section )</div></li><li><div class=fn>void <a href="#released"><b>released</b></a> ( int&nbsp;section )</div></li><li><div class=fn>void <a href="#sizeChange"><b>sizeChange</b></a> ( int&nbsp;section, int&nbsp;oldSize, int&nbsp;newSize )</div></li><li><div class=fn>void <a href="#indexChange"><b>indexChange</b></a> ( int&nbsp;section, int&nbsp;fromIndex, int&nbsp;toIndex )</div></li><li><div class=fn>void sectionClicked ( int&nbsp;index ) &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>void moved ( int&nbsp;fromIndex, int&nbsp;toIndex ) &nbsp;<em>(obsolete)</em></div></li></ul><h2>属性</h2><ul><li><div class=fn>int <a href="#count-prop"><b>count</b></a>&nbsp;- 标题中的节(section)数&nbsp;<em>(read only)</em></div></li><li><div class=fn>bool <a href="#moving-prop"><b>moving</b></a>&nbsp;- 标题节是否可以被移动</div></li><li><div class=fn>int <a href="#offset-prop"><b>offset</b></a>&nbsp;- 标题最左(或者最上)可见的象素</div></li><li><div class=fn>Orientation <a href="#orientation-prop"><b>orientation</b></a>&nbsp;- 标题的物理朝向</div></li><li><div class=fn>bool <a href="#stretching-prop"><b>stretching</b></a>&nbsp;- 标题的节是否总是占据标题的全部宽度(或者高度)</div></li><li><div class=fn>bool <a href="#tracking-prop"><b>tracking</b></a>&nbsp;- 信号sizeChange()是否被连续发送</div></li></ul><h2>保护成员</h2><ul><li><div class=fn>QRect <a href="#sRect"><b>sRect</b></a> ( int&nbsp;index )</div></li><li><div class=fn>virtual void <a href="#paintSection"><b>paintSection</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;index, const&nbsp;QRect&nbsp;&amp;&nbsp;fr )</div></li><li><div class=fn>virtual void <a href="#paintSectionLabel"><b>paintSectionLabel</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;index, const&nbsp;QRect&nbsp;&amp;&nbsp;fr )</div></li></ul><hr><a name="details"></a><h2>详细描述</h2>QHeader类为诸如表格和列表(listview)等提供标题行或者列。<p>本类提供一个标题,例如一个垂直标题显示行标签,或者一个水平标题显示列标签。它可以用于诸如<a href="qtable.html">QTable</a>和<a href="qlistview.html">QListView</a>中。<p>标题由一个或者很多节组成,每个节都可以显示一个文本标签和一个图标(iconset)。使用<a href="#setSortIndicator">setSortIndicator</a>(),还可以显示排序指示器(箭头)。<p>使用<a href="#addLabel">addLabel</a>()添加节,使用<a href="#removeLabel">removeLabel</a>()删去节。标签和图标在addLabel()中设置,以后可以用<a href="#setLabel">setLabel</a>()来修改。使用<a href="#count">count</a>()以得到标题中节的数目。<p>标题的朝向用<a href="#setOrientation">setOrientation</a>()来设置。如果<a href="#setStretchEnabled">setStretchEnabled</a>()为TRUE,节将会占据标题的全部宽度(对于垂直标题则是全部高度)。如果<a href="#setResizeEnabled">setResizeEnabled</a>()为TRUE,用户可以手动调整节的大小。调用<a href="#adjustHeaderSize">adjustHeaderSize</a>(),可以调整节的大小,占据全部宽度(或者高度)。<p>可以使用<a href="#moveSection">moveSection</a>()以移动节。如果<a href="#setMovingEnabled">setMovingEnabled</a>()为TRUE,用户可以把节拖来拖去。如果某个节被移动,节被添加(使用<a href="#addLabel">addLabel</a>())时的索引位置就可能与移动之后不同了。实际上你不必担心这一点,因为QHeader的API是使用节的编号(section number)的术语来工作的,某特定的节被移到哪里并没有关系。<p>如果你想得到一个节的当前索引位置,可以以节编号为参数调用<a href="#mapToIndex">mapToIndex</a>()。(这个节编号是由生成该节的addLabel()调用所返回的数值。)如果你想得到一个具体索引位置的节的编号,可以以索引位置为参数调用<a href="#mapToSection">mapToSection</a>()。<p>下面是阐明mapToSection()和mapToIndex()的例子:<p> <center><table cellpadding="4" cellspacing="2" border="0"><tr bgcolor="#a2c511"> <th valign="top" colspan="4" rowspan="1">索引位置<tr bgcolor="#f0f0f0"> <td valign="top">0<td valign="top">1<td valign="top">2<td valign="top">3<tr bgcolor="#a2c511"> <th valign="top" colspan="4" rowspan="1">原来的节次序<tr bgcolor="#d0d0d0"> <td valign="top">Sect 0<td valign="top">Sect 1<td valign="top">Sect 2<td valign="top">Sect 3<tr bgcolor="#a2c511"> <th valign="top" colspan="4" rowspan="1">用户移动一个节之后的次序<tr bgcolor="#f0f0f0"> <td valign="top">Sect 0<td valign="top">Sect 2<td valign="top">Sect 3<td valign="top">Sect 1</table></center><p> <center><table cellpadding="4" cellspacing="2" border="0"><tr bgcolor="#a2c511"> <th valign="top"><em>k</em><th valign="top">mapToSection(<em>k</em>)<th valign="top">mapToIndex(<em>k</em>)<tr bgcolor="#d0d0d0"> <td valign="top">0 <td valign="top">0 <td valign="top">0<tr bgcolor="#f0f0f0"> <td valign="top">1 <td valign="top">2 <td valign="top">3<tr bgcolor="#d0d0d0"> <td valign="top">2 <td valign="top">3 <td valign="top">1<tr bgcolor="#f0f0f0"> <td valign="top">3 <td valign="top">1 <td valign="top">2

⌨️ 快捷键说明

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