?? qheader.html
字號:
<!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 <<a href="qheader-h.html">qheader.h</a>></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 * parent = 0, const char * name = 0 )</div></li><li><div class=fn><a href="#QHeader-2"><b>QHeader</b></a> ( int n, QWidget * parent = 0, const char * 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 QString & s, int size = -1 )</div></li><li><div class=fn>int <a href="#addLabel-2"><b>addLabel</b></a> ( const QIconSet & iconset, const QString & s, int size = -1 )</div></li><li><div class=fn>void <a href="#removeLabel"><b>removeLabel</b></a> ( int section )</div></li><li><div class=fn>virtual void <a href="#setLabel"><b>setLabel</b></a> ( int section, const QString & s, int size = -1 )</div></li><li><div class=fn>virtual void <a href="#setLabel-2"><b>setLabel</b></a> ( int section, const QIconSet & iconset, const QString & s, int size = -1 )</div></li><li><div class=fn>QString <a href="#label"><b>label</b></a> ( int section ) const</div></li><li><div class=fn>QIconSet * <a href="#iconSet"><b>iconSet</b></a> ( int 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 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 enable, int section = -1 )</div></li><li><div class=fn>virtual void <a href="#setResizeEnabled"><b>setResizeEnabled</b></a> ( bool enable, int 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 b, int section )</div></li><li><div class=fn>void <a href="#setStretchEnabled-2"><b>setStretchEnabled</b></a> ( bool b )</div></li><li><div class=fn>bool <a href="#isClickEnabled"><b>isClickEnabled</b></a> ( int section = -1 ) const</div></li><li><div class=fn>bool <a href="#isResizeEnabled"><b>isResizeEnabled</b></a> ( int 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 section ) const</div></li><li><div class=fn>void <a href="#resizeSection"><b>resizeSection</b></a> ( int section, int s )</div></li><li><div class=fn>int <a href="#sectionSize"><b>sectionSize</b></a> ( int section ) const</div></li><li><div class=fn>int <a href="#sectionPos"><b>sectionPos</b></a> ( int section ) const</div></li><li><div class=fn>int <a href="#sectionAt"><b>sectionAt</b></a> ( int 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 section ) const</div></li><li><div class=fn>virtual void setCellSize ( int section, int s ) <em>(obsolete)</em></div></li><li><div class=fn>int cellSize ( int i ) const <em>(obsolete)</em></div></li><li><div class=fn>int cellPos ( int i ) const <em>(obsolete)</em></div></li><li><div class=fn>int cellAt ( int pos ) const <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 index ) const</div></li><li><div class=fn>int <a href="#mapToIndex"><b>mapToIndex</b></a> ( int section ) const</div></li><li><div class=fn>int mapToLogical ( int a ) const <em>(obsolete)</em></div></li><li><div class=fn>int mapToActual ( int l ) const <em>(obsolete)</em></div></li><li><div class=fn>void <a href="#moveSection"><b>moveSection</b></a> ( int section, int toIndex )</div></li><li><div class=fn>virtual void moveCell ( int fromIdx, int toIdx ) <em>(obsolete)</em></div></li><li><div class=fn>void <a href="#setSortIndicator"><b>setSortIndicator</b></a> ( int section, bool 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 pos )</div></li></ul><h2>信號</h2><ul><li><div class=fn>void <a href="#clicked"><b>clicked</b></a> ( int section )</div></li><li><div class=fn>void <a href="#pressed"><b>pressed</b></a> ( int section )</div></li><li><div class=fn>void <a href="#released"><b>released</b></a> ( int section )</div></li><li><div class=fn>void <a href="#sizeChange"><b>sizeChange</b></a> ( int section, int oldSize, int newSize )</div></li><li><div class=fn>void <a href="#indexChange"><b>indexChange</b></a> ( int section, int fromIndex, int toIndex )</div></li><li><div class=fn>void sectionClicked ( int index ) <em>(obsolete)</em></div></li><li><div class=fn>void moved ( int fromIndex, int toIndex ) <em>(obsolete)</em></div></li></ul><h2>屬性</h2><ul><li><div class=fn>int <a href="#count-prop"><b>count</b></a> - 標題中的節(section)數 <em>(read only)</em></div></li><li><div class=fn>bool <a href="#moving-prop"><b>moving</b></a> - 標題節是否可以被移動</div></li><li><div class=fn>int <a href="#offset-prop"><b>offset</b></a> - 標題最左(或者最上)可見的象素</div></li><li><div class=fn>Orientation <a href="#orientation-prop"><b>orientation</b></a> - 標題的物理朝向</div></li><li><div class=fn>bool <a href="#stretching-prop"><b>stretching</b></a> - 標題的節是否總是占據標題的全部寬度(或者高度)</div></li><li><div class=fn>bool <a href="#tracking-prop"><b>tracking</b></a> - 信號sizeChange()是否被連續發送</div></li></ul><h2>保護成員</h2><ul><li><div class=fn>QRect <a href="#sRect"><b>sRect</b></a> ( int index )</div></li><li><div class=fn>virtual void <a href="#paintSection"><b>paintSection</b></a> ( QPainter * p, int index, const QRect & fr )</div></li><li><div class=fn>virtual void <a href="#paintSectionLabel"><b>paintSectionLabel</b></a> ( QPainter * p, int index, const QRect & 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 + -