?? qheader.html
字號:
</table></center><p>在上面的例子中,如果我們要找出哪個節在索引位置3,可以調用<a href="#mapToSection">mapToSection</a>(3),就會得到節編號為1,因為節1被移動到了那里。類似地,如果我們要知道節2占據了哪個索引位置,調用<a href="#mapToIndex">mapToIndex</a>(2),就會得到索引為1。<p>QHeader提供了<a href="#clicked">clicked</a>()、<a href="#pressed">pressed</a>()和<a href="#released">released</a>()信號。如果用戶改變了某個節的大小,<a href="#sizeChange">sizeChange</a>()信號被發送。如果你希望sizeChange()信號在用戶調整大小時持續被發送(而不是只在調整后),使用<a href="#setTracking">setTracking</a>()。如果用戶移動了節,<a href="#indexChange">indexChange</a>()信號被發送。<p> <img src=qheader-m.png> <img src=qheader-w.png><p> <p>也參見<a href="qlistview.html">QListView</a>、<a href="qtable.html">QTable</a>和<a href="advanced.html">高級部件</a>。<hr><h2>成員函數文檔</h2><h3 class=fn><a name="QHeader"></a>QHeader::QHeader ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )</h3>構造一個水平標題,命名為<em>name</em>,父部件為<em>parent</em>。<p> <h3 class=fn><a name="QHeader-2"></a>QHeader::QHeader ( int n, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )</h3>構造一個水平標題,命名為<em>name</em>,由<em>n</em>節組成,父部件為<em>parent</em>。<p> <h3 class=fn><a name="~QHeader"></a>QHeader::~QHeader ()</h3>銷毀標題及其節。<h3 class=fn>int <a name="addLabel"></a>QHeader::addLabel ( const <a href="qstring.html">QString</a> & s, int size = -1 )</h3>增加一個新節,標簽文本為<em>s</em>。返回節所加在的索引位置(對于水平標題是在右邊,對于垂直標題是在下邊)。節的寬度設置為<em>size</em>。若<em>size</em> < 0,則根據文本<em>s</em>來選擇合適的大小。<h3 class=fn>int <a name="addLabel-2"></a>QHeader::addLabel ( const <a href="qiconset.html">QIconSet</a> & iconset, const <a href="qstring.html">QString</a> & s, int size = -1 )</h3>這是重載的成員函數,為便利而提供。其行為本質上類似上一個函數。<p>增加一個帶有圖標<em>iconset</em>和標簽文本<em>s</em>的新節。返回節所加在的索引位置(對于水平標題是在右邊,對于垂直標題是在下邊)。節的寬度設置為<em>size</em>。若<em>size</em> < 0,則根據文本來選擇合適的大小。<p><h3 class=fn>void <a name="adjustHeaderSize"></a>QHeader::adjustHeaderSize ()</h3><p>調整節的大小,以盡可能全部占據標題的大小。只有<a href="#isStretchEnabled">isStretchEnabled</a>()為TRUE的那些節會被調整大小。<p><h3 class=fn>int <a name="cellAt"></a>QHeader::cellAt ( int pos ) const</h3><b>本函數已經廢棄。</b>為支持舊代碼運行而提供,強烈建議新代碼中不要使用。<p>使用<a href="#sectionAt">sectionAt</a>()來代替本函數。<p> Returns the index at which the section is displayed, which contains<em>pos</em> in widget coordinates, or -1 if <em>pos</em> is outside the headersections.<h3 class=fn>int <a name="cellPos"></a>QHeader::cellPos ( int i ) const</h3><b>本函數已經廢棄。</b>為支持舊代碼運行而提供,強烈建議新代碼中不要使用。<p>使用<a href="#sectionPos">sectionPos</a>()來代替本函數。<p> Returns the position in pixels of the section that is displayed at theindex <em>i</em>。 The position is measured from the start of the header.<h3 class=fn>int <a name="cellSize"></a>QHeader::cellSize ( int i ) const</h3><b>本函數已經廢棄。</b>為支持舊代碼運行而提供,強烈建議新代碼中不要使用。<p>使用<a href="#sectionSize">sectionSize</a>()來代替本函數。<p> Returns the size in pixels of the section that is displayed atthe index <em>i</em>。<h3 class=fn>void <a name="clicked"></a>QHeader::clicked ( int section )<tt> [信號]</tt></h3><p>如果<a href="#isClickEnabled">isClickEnabled</a>()為TRUE,當用戶點擊節<em>section</em>時,本信號被發送。<p> <p>也參見<a href="#pressed">pressed</a>()和<a href="#released">released</a>()。<h3 class=fn>int <a name="count"></a>QHeader::count () const</h3><p>返回標題中的節的數目。詳見<a href="qheader.html#count-prop">"count"</a>屬性。<h3 class=fn>int <a name="headerWidth"></a>QHeader::headerWidth () const</h3>返回所有標題列的總寬度。<h3 class=fn><a href="qiconset.html">QIconSet</a> * <a name="iconSet"></a>QHeader::iconSet ( int section ) const</h3>返回節<em>section</em>的圖標。如果該節不存在,返回0。<h3 class=fn>void <a name="indexChange"></a>QHeader::indexChange ( int section, int fromIndex, int toIndex )<tt> [信號]</tt></h3><p>當用戶把節<em>section</em>從索引位置<em>fromIndex</em>移到索引位置<em>toIndex</em>時,本信號被發送。<h3 class=fn>bool <a name="isClickEnabled"></a>QHeader::isClickEnabled ( int section = -1 ) const</h3>如果節<em>section</em>為可點擊,返回TRUE;否則返回FALSE。<p>在<em>section</em>超出范圍時(為負或者大于<a href="#count">count</a>() - 1),如果所有節都是可點擊,返回TRUE,否則返回FALSE。<p> <p>也參見<a href="#setClickEnabled">setClickEnabled</a>()。<h3 class=fn>bool <a name="isMovingEnabled"></a>QHeader::isMovingEnabled () const</h3><p>如果標題節可以被移動,返回TRUE;否則返回FALSE。詳見<a href="qheader.html#moving-prop">"moving"</a>屬性。<h3 class=fn>bool <a name="isResizeEnabled"></a>QHeader::isResizeEnabled ( int section = -1 ) const</h3>如果節<em>section</em>為可調整大小,返回TRUE;否則返回FALSE。<p>如果<em>section</em>為-1,本函數應用于所有節,也就是說,如果所有節都是可調整大小的,返回TRUE;否則返回FALSE。<p> <p>也參見<a href="#setResizeEnabled">setResizeEnabled</a>()。<h3 class=fn>bool <a name="isStretchEnabled"></a>QHeader::isStretchEnabled () const</h3><p>如果標題節總是占據標題的全部寬度(或者高度),返回TRUE;否則返回FALSE。詳見<a href="qheader.html#stretching-prop">"stretching"</a>屬性。<h3 class=fn>bool <a name="isStretchEnabled-2"></a>QHeader::isStretchEnabled ( int section ) const</h3>如果節<em>section</em>可以調整大小以占據標題的全部寬度(或者高度),返回TRUE;否則返回FALSE。如果至少一個節是可伸縮的,節就總是占據標題的全部寬度。<p> <p>也參見<a href="#setStretchEnabled">setStretchEnabled</a>()。<h3 class=fn><a href="qstring.html">QString</a> <a name="label"></a>QHeader::label ( int section ) const</h3>返回節<em>section</em>的文本。如果該節不存在,返回空字符串。<h3 class=fn>int <a name="mapToActual"></a>QHeader::mapToActual ( int l ) const</h3><b>本函數已經廢棄。</b>為支持舊代碼運行而提供,強烈建議新代碼中不要使用。<p>使用<a href="#mapToIndex">mapToIndex</a>()來代替本函數。<p> Translates from logical index <em>l</em> to actual index (index at which the section <em>l</em> is displayed) .Returns -1 if <em>l</em> is outside the legal range.<p> <p>也參見<a href="#mapToLogical">mapToLogical</a>()。<h3 class=fn>int <a name="mapToIndex"></a>QHeader::mapToIndex ( int section ) const</h3>返回節<em>section</em>當前被顯示的索引。<p>更多解釋參見<a href="#mapexample">mapTo例子</a>。<h3 class=fn>int <a name="mapToLogical"></a>QHeader::mapToLogical ( int a ) const</h3><b>本函數已經廢棄。</b>為支持舊代碼運行而提供,強烈建議新代碼中不要使用。<p>使用<a href="#mapToSection">mapToSection</a>()來代替本函數。<p> Translates from actual index <em>a</em> (index at which the section is displayed) tological index of the section. Returns -1 if <em>a</em> is outside the legal range.<p> <p>也參見<a href="#mapToActual">mapToActual</a>()。<h3 class=fn>int <a name="mapToSection"></a>QHeader::mapToSection ( int index ) const</h3>返回顯示于索引位置<em>index</em>的節。<p>更多解釋參見<a href="#mapexample">mapTo例子</a>。<h3 class=fn>void <a name="moveCell"></a>QHeader::moveCell ( int fromIdx, int toIdx )<tt> [虛]</tt></h3><b>本函數已經廢棄。</b>為支持舊代碼運行而提供,強烈建議新代碼中不要使用。<p>使用<a href="#moveSection">moveSection</a>()來代替本函數。<p> Moves the section that is currently displayed at index <em>fromIdx</em>to index <em>toIdx</em>。<h3 class=fn>void <a name="moveSection"></a>QHeader::moveSection ( int section, int toIndex )</h3>把節<em>section</em>移到索引位置<em>toIndex</em>。<h3 class=fn>void <a name="moved"></a>QHeader::moved ( int fromIndex, int toIndex )<tt> [信號]</tt></h3><b>本函數已經廢棄。</b>為支持舊代碼運行而提供,強烈建議新代碼中不要使用。<p>使用<a href="#indexChange">indexChange</a>()來代替本函數。<p> This signal is emitted when the user has moved the section whichis displayed at the index <em>fromIndex</em> to the index <em>toIndex</em>。<h3 class=fn>int <a name="offset"></a>QHeader::offset () const</h3><p>返回標題的最左(或者最上)的可見象素。詳見<a href="qheader.html#offset-prop">"offset"</a>屬性。<h3 class=fn><a href="qt.html#Orientation-enum">Orientation</a> <a name="orientation"></a>QHeader::orientation () const</h3><p>返回標題的物理朝向。詳見<a href="qheader.html#orientation-prop">"orientation"</a>屬性。<h3 class=fn>void <a name="paintSection"></a>QHeader::paintSection ( <a href="qpainter.html">QPainter</a> * p, int index, const <a href="qrect.html">QRect</a> & fr )<tt> [虛 保護]</tt></h3>在矩形<em>fr</em>內(使用部件坐標),使用畫具<em>p</em>繪制在位置<em>index</em>的節。<p>調用了<a href="#paintSectionLabel">paintSectionLabel</a>()。<h3 class=fn>void <a name="paintSectionLabel"></a>QHeader::paintSectionLabel ( <a href="qpainter.html">QPainter</a> * p, int index, const <a href="qrect.html">QRect</a> & fr )<tt> [虛 保護]</tt></h3>在矩形<em>fr</em>內(使用部件坐標),使用畫具<em>p</em>繪制在位置<em>index</em>的節的標簽。<p>被<a href="#paintSection">paintSection</a>()所調用。<h3 class=fn>void <a name="pressed"></a>QHeader::pressed ( int section )<tt> [信號]</tt></h3>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -