📄 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 + -