QHeaderView Class
QHeaderViewクラスは、アイテムビューのヘッダー行またはヘッダー列を提供します。詳細...
ヘッダー | #include <QHeaderView> |
CMake.QHeaderViewクラスは、ヘッダー行またはヘッダー列を提供します: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
継承: | QAbstractItemView |
パブリックな型
enum | ResizeMode { Interactive, Fixed, Stretch, ResizeToContents, Custom } |
プロパティ
|
|
パブリック関数
QHeaderView(Qt::Orientation orientation, QWidget *parent = nullptr) | |
virtual | ~QHeaderView() |
bool | cascadingSectionResizes() const |
int | count() const |
Qt::Alignment | defaultAlignment() const |
int | defaultSectionSize() const |
int | hiddenSectionCount() const |
void | hideSection(int logicalIndex) |
bool | highlightSections() const |
bool | isFirstSectionMovable() const |
bool | isSectionHidden(int logicalIndex) const |
bool | isSortIndicatorClearable() const |
bool | isSortIndicatorShown() const |
int | length() const |
int | logicalIndex(int visualIndex) const |
int | logicalIndexAt(const QPoint &pos) const |
int | logicalIndexAt(int position) const |
int | logicalIndexAt(int x, int y) const |
int | maximumSectionSize() const |
int | minimumSectionSize() const |
void | moveSection(int from, int to) |
int | offset() const |
Qt::Orientation | orientation() const |
void | resetDefaultSectionSize() |
int | resizeContentsPrecision() const |
void | resizeSection(int logicalIndex, int size) |
void | resizeSections(QHeaderView::ResizeMode mode) |
bool | restoreState(const QByteArray &state) |
QByteArray | saveState() const |
int | sectionPosition(int logicalIndex) const |
QHeaderView::ResizeMode | sectionResizeMode(int logicalIndex) const |
int | sectionSize(int logicalIndex) const |
int | sectionSizeHint(int logicalIndex) const |
int | sectionViewportPosition(int logicalIndex) const |
bool | sectionsClickable() const |
bool | sectionsHidden() const |
bool | sectionsMovable() const |
bool | sectionsMoved() const |
void | setCascadingSectionResizes(bool enable) |
void | setDefaultAlignment(Qt::Alignment alignment) |
void | setDefaultSectionSize(int size) |
void | setFirstSectionMovable(bool movable) |
void | setHighlightSections(bool highlight) |
void | setMaximumSectionSize(int size) |
void | setMinimumSectionSize(int size) |
void | setResizeContentsPrecision(int precision) |
void | setSectionHidden(int logicalIndex, bool hide) |
void | setSectionResizeMode(QHeaderView::ResizeMode mode) |
void | setSectionResizeMode(int logicalIndex, QHeaderView::ResizeMode mode) |
void | setSectionsClickable(bool clickable) |
void | setSectionsMovable(bool movable) |
void | setSortIndicator(int logicalIndex, Qt::SortOrder order) |
void | setSortIndicatorClearable(bool clearable) |
void | setSortIndicatorShown(bool show) |
void | setStretchLastSection(bool stretch) |
void | showSection(int logicalIndex) |
Qt::SortOrder | sortIndicatorOrder() const |
int | sortIndicatorSection() const |
bool | stretchLastSection() const |
int | stretchSectionCount() const |
void | swapSections(int first, int second) |
int | visualIndex(int logicalIndex) const |
int | visualIndexAt(int position) const |
再実装パブリック関数
virtual void | reset() override |
virtual void | setModel(QAbstractItemModel *model) override |
virtual void | setVisible(bool v) override |
virtual QSize | sizeHint() const override |
パブリック・スロット
void | headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast) |
void | setOffset(int offset) |
void | setOffsetToLastSection() |
void | setOffsetToSectionPosition(int visualSectionNumber) |
シグナル
void | geometriesChanged() |
void | sectionClicked(int logicalIndex) |
void | sectionCountChanged(int oldCount, int newCount) |
void | sectionDoubleClicked(int logicalIndex) |
void | sectionEntered(int logicalIndex) |
void | sectionHandleDoubleClicked(int logicalIndex) |
void | sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex) |
void | sectionPressed(int logicalIndex) |
void | sectionResized(int logicalIndex, int oldSize, int newSize) |
void | sortIndicatorChanged(int logicalIndex, Qt::SortOrder order) |
void | sortIndicatorClearableChanged(bool clearable) |
保護された関数
virtual void | initStyleOption(QStyleOptionHeader *option) const |
(since 6.0) virtual void | initStyleOptionForIndex(QStyleOptionHeader *option, int logicalIndex) const |
virtual void | paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const |
virtual QSize | sectionSizeFromContents(int logicalIndex) const |
再実装された保護された関数
virtual void | currentChanged(const QModelIndex ¤t, const QModelIndex &old) override |
virtual bool | event(QEvent *e) override |
virtual int | horizontalOffset() const override |
virtual void | mouseDoubleClickEvent(QMouseEvent *e) override |
virtual void | mouseMoveEvent(QMouseEvent *e) override |
virtual void | mousePressEvent(QMouseEvent *e) override |
virtual void | mouseReleaseEvent(QMouseEvent *e) override |
virtual void | paintEvent(QPaintEvent *e) override |
virtual void | setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override |
virtual int | verticalOffset() const override |
virtual bool | viewportEvent(QEvent *e) override |
保護されたスロット
void | resizeSections() |
void | sectionsAboutToBeRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast) |
void | sectionsInserted(const QModelIndex &parent, int logicalFirst, int logicalLast) |
詳細説明
QHeaderView は、QTableView やQTreeView クラスのようなアイテムビューで使用されるヘッダーを表示します。これは、以前同じ目的で使用されていた Qt3 のQHeader
クラスの代わりとなるものですが、アイテムビュークラスとの一貫性を保つために Qt のモデル/ビューアーキテクチャを使用しています。
QHeaderViewクラスはモデル/ビュー・クラスの1つで、Qtのモデル/ビュー・フレームワークの一部です。
ヘッダーは、QAbstractItemModel::headerData ()関数を使用してモデルから各セクションのデータを取得します。データを設定するには、QAbstractItemModel::setHeaderData ()を使用します。
各ヘッダーは、orientation() と、count() 関数で指定された数のセクションを持ちます。セクションは、ヘッダーの一部分を指し、向きによって行または列のいずれかになります。
セクションは、moveSection() とresizeSection() を使用して移動したりサイズを変更したりできます。また、hideSection() とshowSection() を使用して非表示にしたり表示したりすることもできます。
ヘッダーの各セクションは、section()で指定されたセクションIDで記述され、 ヘッダー内の特定のvisualIndex()に配置することができる。セクションは、setSortIndicator() でソート・インジケータを設定できます。これは、関連するアイテム・ビューのアイテムが、セクションで指定された順序でソートされるかどうかを示します。
水平ヘッダーの場合、セクションはモデルの列に相当し、垂直ヘッダーの場合、セクションはモデルの行に相当します。
ヘッダーセクションの移動
ヘッダーは固定することも、setSectionsMovable()で移動可能にすることもできます。また、setSectionsClickable() でクリック可能にすることができ、setSectionResizeMode() に従ったリサイズ動作があります。
注: セクションのサイズを変更するためにヘッダーをダブルクリックすることは、表示されている行にのみ適用されます。
ヘッダーは、ユーザーがセクションを移動した場合、sectionMoved()を 発し、ユーザーがセクションのサイズを変更した場合、sectionResized()を 発し、マウスクリックに応答してsectionClicked()とsectionHandleDoubleClicked()を発する。また、ヘッダーもsectionCountChanged ()を出力します。
セクションを識別するには、logicalIndex ()とlogicalIndexAt ()関数を使用するか、visualIndex ()とvisualIndexAt ()関数を使用してインデックス位置を指定します。セクションが移動した場合、視覚的なインデックスは変更されますが、論理的なインデックスは変更されません。
外観
QTableWidget と はデフォルトのヘッダーを作成します。ヘッダーを表示させたい場合は、 () を使用します。QTableView setVisible
すべてのItemDataRoleがQHeaderViewに影響を与えるわけではありません。他のロールを描画する必要がある場合は、QHeaderViewをサブクラス化し、paintEvent ()を再実装することができます。QHeaderViewは、スタイルと競合しない限り(デスクトップ・テーマに従ったスタイルで発生する可能性がある)、以下の項目データ・ロールを尊重します:
TextAlignmentRole DisplayRole 、 、 、 、 。FontRole DecorationRole ForegroundRole BackgroundRole
注: 各ヘッダーは各セクションのデータをレンダリングし、デリゲートには依存しません。そのため、ヘッダーのsetItemDelegate() 関数を呼び出しても効果はありません。
モデル/ビュー・プログラミング、QListView 、QTableView 、QTreeViewも参照してください 。
メンバ型ドキュメント
enum QHeaderView::ResizeMode
リサイズモードはヘッダーセクションの動作を指定します。ヘッダービュー全体か、setSectionResizeMode() を使って個々のセクションに設定できます。
定数 | 値 | 説明 |
---|---|---|
QHeaderView::Interactive | 0 | ユーザはセクションのサイズを変更できます。また、resizeSection() を使用して、プログラムでセクションのサイズを変更することもできます。セクション・サイズのデフォルトはdefaultSectionSize です (cascadingSectionResizes も参照)。 |
QHeaderView::Fixed | 2 | ユーザーはセクションのサイズを変更できません。セクションのサイズを変更できるのは、resizeSection() を使用したプログラムのみです。セクション・サイズのデフォルトはdefaultSectionSize です。 |
QHeaderView::Stretch | 1 | QHeaderView を使用すると、利用可能なスペースを埋めるようにセクションのサイズが自動的に変更されます。このサイズは、ユーザーまたはプログラムによって変更することはできません。 |
QHeaderView::ResizeToContents | 3 | QHeaderView は、列全体または行全体の内容に基づいて、セクションのサイズを自動的に最適なサイズに変更します。このサイズは、ユーザーやプログラムによって変更することはできません。(この値は4.2で導入されました) |
以下の値は廃止されました:
定数 | 値 | 説明 |
---|---|---|
QHeaderView::Custom | Fixed | 代わりに Fixed を使用してください。 |
setSectionResizeMode()、stretchLastSection 、およびminimumSectionSizeも参照してください 。
プロパティ・ドキュメンテーション
cascadingSectionResizes : bool
このプロパティは、ユーザーによってリサイズされているセクションが最小サイズに達すると、インタラクティブなリサイズが次のセクションにカスケードされるかどうかを保持します。
このプロパティは、リサイズモードとしてInteractive を持つセクションにのみ影響します。
デフォルト値はfalseです。
アクセス関数:
bool | cascadingSectionResizes() const |
void | setCascadingSectionResizes(bool enable) |
setSectionResizeMode()も参照 。
defaultAlignment : Qt::Alignment
このプロパティは、各ヘッダーセクションのテキストのデフォルトの配置を保持します。
アクセス関数:
Qt::Alignment | defaultAlignment() const |
void | setDefaultAlignment(Qt::Alignment alignment) |
defaultSectionSize : int
このプロパティは、リサイズ前のヘッダーセクションのデフォルトサイズを保持する。
このプロパティは、リサイズモードとしてInteractive またはFixed を持つセクションにのみ影響します。
デフォルトでは、このプロパティの値はスタイルに依存します。したがって、スタイルが変更されると、このプロパティも変更されます。setDefaultSectionSize()を呼び出すと更新が停止し、resetDefaultSectionSize()を呼び出すとデフォルトの動作に戻ります。
関数にアクセスします:
int | defaultSectionSize() const |
void | setDefaultSectionSize(int size) |
void | resetDefaultSectionSize() |
setSectionResizeMode() およびminimumSectionSizeも参照してください 。
firstSectionMovable : bool
このプロパティは、最初の列がユーザーによって移動できるかどうかを保持する
このプロパティは、最初のカラムをユーザーが移動できるかどうかを制御します。QTreeView の場合、最初の列はツリー構造を保持しているため、setSectionsMovable(true)の後でも、デフォルトでは移動不可能です。
例えば、ツリー構造を持たないフラット・リストの場合、このメソッドを呼び出すことで、再び移動可能にすることができます。そのような場合は、QTreeView::setRootIsDecorated (false)も呼び出すことを推奨する。
treeView->setRootIsDecorated(false); treeView->header()->setFirstSectionMovable(true);
このメソッドをtrueに設定しても、setSectionsMovable (true)を呼び出さない限り、効果はない。
関数にアクセスする:
bool | isFirstSectionMovable() const |
void | setFirstSectionMovable(bool movable) |
setSectionsMovable()も参照のこと 。
highlightSections : bool
このプロパティは、選択された項目を含むセクションがハイライトされるかどうかを保持する。
デフォルトでは、このプロパティはfalse
です。
アクセス関数:
bool | highlightSections() const |
void | setHighlightSections(bool highlight) |
maximumSectionSize : int
このプロパティは、ヘッダーセクションの最大サイズを保持する。
最大セクションサイズは、許容される最大のセクションサイズである。このプロパティのデフォルト値は 1048575 で、これはセクションで可能な最大のサイズでもあります。maximumを-1に設定すると、値は最大のセクションサイズにリセットされます。
stretch を除き、このプロパティはすべてのresize modes
アクセス関数によって尊重されます:
int | maximumSectionSize() const |
void | setMaximumSectionSize(int size) |
setSectionResizeMode() およびdefaultSectionSizeも参照してください 。
minimumSectionSize : int
このプロパティは、ヘッダーセクションの最小サイズを保持する。
最小セクション・サイズは、許容される最小のセクション・サイズである。最小セクション・サイズを -1 に設定すると、QHeaderView はfont metrics のサイズを使用する。
このプロパティは、すべてのresize modes 。
アクセス関数によって尊重されます:
int | minimumSectionSize() const |
void | setMinimumSectionSize(int size) |
setSectionResizeMode() およびdefaultSectionSizeも参照のこと 。
sectionsClickable : bool
ヘッダーがクリッカブルであればtrue
を保持し、そうでなければfalse
を保持する。クリック可能なヘッダーは、ユーザーがヘッダーに関連するビューのデータの表現を変更できるように設定できる。
アクセス関数:
bool | sectionsClickable() const |
void | setSectionsClickable(bool clickable) |
sectionPressed() およびsetSortIndicatorShown()も参照の こと。
sectionsMovable : bool
sectionsMovable がtrueの場合、ヘッダーセクションはユーザーが動かすことができる。
QTreeView と組み合わせて使用される場合、デフォルトでは、最初のカラムは移動できません (ツリー構造を含むため)。setFirstSectionMovable(true)で移動可能にすることができる。
アクセス関数:
bool | sectionsMovable() const |
void | setSectionsMovable(bool movable) |
sectionMoved() およびsetFirstSectionMovable()も参照のこと 。
showSortIndicator : bool
このプロパティは、ソートインジケータを表示するかどうかを保持する。
デフォルトでは、このプロパティはfalse
です。
アクセス関数:
bool | isSortIndicatorShown() const |
void | setSortIndicatorShown(bool show) |
setSectionsClickable()も参照してください 。
[since 6.1]
sortIndicatorClearable : bool
このプロパティは、セクションを複数回クリックすることによってソートインジケータを消去できるかどうかを保持する
このプロパティは、ユーザがセクションを複数回クリックすることによって、指定されたセクションのソート・インジケータを取り除くことができるかどうかを制御する。通常、セクションをクリックすると、そのセクションのソート順が変更されます。このプロパティをtrueに設定すると、昇順と降順が交互に繰り返された後、ソート・インジケータは消去されます。これは通常、モデルの元のソートを復元します。
このプロパティをtrueに設定しても、sectionsClickable ()もtrueでない限り(これは、QTableView などの特定のビューのデフォルトであるか、QTreeView::setSortingEnabled を呼び出すなどしてビューをソート可能にするときに自動的に設定される)、何の効果もありません。
このプロパティは Qt 6.1 で導入されました。
アクセス関数:
bool | isSortIndicatorClearable() const |
void | setSortIndicatorClearable(bool clearable) |
通知シグナル:
void | sortIndicatorClearableChanged(bool clearable) |
stretchLastSection : bool
このプロパティは、ヘッダの最後の可視セクションが利用可能なすべてのスペースを占めるかどうかを保持します。
デフォルト値はfalseです。
注意: QTreeView によって提供される水平ヘッダーは、ビューがそのヘッダーのために割り当てられたスペースを無駄にしないことを保証するために、このプロパティがtrueに設定された状態で構成されます。この値がtrueに設定されている場合、このプロパティは、ヘッダーの最後のセクションに設定されているリサイズモードを上書きします。
アクセス関数:
bool | stretchLastSection() const |
void | setStretchLastSection(bool stretch) |
setSectionResizeMode()も参照 。
メンバ関数ドキュメント
[explicit]
QHeaderView::QHeaderView(Qt::Orientation orientation, QWidget *parent = nullptr)
与えられたorientation とparent で新しい汎用ヘッダを作成する。
[virtual noexcept]
QHeaderView::~QHeaderView()
ヘッダーを破壊する。
int QHeaderView::count() const
ヘッダーのセクション数を返します。
sectionCountChanged() およびlength()も参照ください 。
[override virtual protected]
void QHeaderView::currentChanged(const QModelIndex ¤t, const QModelIndex &old)
再実装:QAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)。
[override virtual protected]
bool QHeaderView::event(QEvent *e)
再実装:QAbstractItemView::event(QEvent *event)。
[signal]
void QHeaderView::geometriesChanged()
このシグナルは、ヘッダーのジオメトリが変更されたときに発せられる。
[slot]
void QHeaderView::headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast)
変更されたヘッダーセクションを、与えられたorientation 、logicalFirst からlogicalLast までを含めて更新する。
int QHeaderView::hiddenSectionCount() const
隠されたヘッダーのセクション数を返します。
setSectionHidden() およびisSectionHidden()も参照 ください。
void QHeaderView::hideSection(int logicalIndex)
logicalIndex で指定されたセクションを隠す。
showSection()、isSectionHidden()、hiddenSectionCount()、setSectionHidden()も参照のこと 。
[override virtual protected]
int QHeaderView::horizontalOffset() const
再実装:QAbstractItemView::horizontalOffset() const.
ヘッダの水平オフセットを返します。垂直ヘッダの場合は 0。
offset()も参照ください 。
[virtual protected]
void QHeaderView::initStyleOption(QStyleOptionHeader *option) const
このQHeaderView の値でoption を初期化する。このメソッドは、サブクラスがQStyleOptionHeader を必要とするが、すべての情報を自分で入力したくない場合に便利です。
QStyleOption::initFrom() およびinitStyleOptionForIndex()も参照してください 。
[virtual protected, since 6.0]
void QHeaderView::initStyleOptionForIndex(QStyleOptionHeader *option, int logicalIndex) const
指定されたlogicalIndex からスタイルoption を初期化する。この関数は、initStyleOption が呼び出された後、paintSection のデフォルト実装によって呼び出されます。
この関数は Qt 6.0 で導入されました。
paintSection() およびinitStyleOption()も参照してください 。
bool QHeaderView::isSectionHidden(int logicalIndex) const
logicalIndex で指定されたセクションが明示的に非表示になっている場合はtrue
を返し、そうでない場合はfalse
を返す。
hideSection()、showSection()、setSectionHidden()、hiddenSectionCount()も参照のこと 。
int QHeaderView::length() const
ヘッダーの向きに沿った長さを返す。
sizeHint()、setSectionResizeMode() およびoffset()も参照 。
int QHeaderView::logicalIndex(int visualIndex) const
与えられたvisualIndex の位置にあるセクションの logicalIndex を返す。visualIndex < 0 またはvisualIndex >=QHeaderView::count() の場合は -1。
visualIndex は非表示セクションの影響を受けないことに注意。
visualIndex() およびsectionPosition()も参照 。
int QHeaderView::logicalIndexAt(const QPoint &pos) const
pos で与えられた位置のセクションの論理インデックスを返す。 ヘッダが水平の場合は x 座標が使われ、そうでない場合は y 座標が論理インデックスを見つけるために使われる。
sectionPosition()も参照 。
int QHeaderView::logicalIndexAt(int position) const
ビューポート内の指定されたposition をカバーするセクションを返す。
visualIndexAt() およびisSectionHidden()も参照 。
int QHeaderView::logicalIndexAt(int x, int y) const
与えられた座標のセクションの論理インデックスを返す。ヘッダーが水平の場合はx が使用され、そうでない場合はy が論理インデックスを見つけるために使用されます。
[override virtual protected]
void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e)
再実装:QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)。
[override virtual protected]
void QHeaderView::mouseMoveEvent(QMouseEvent *e)
再実装:QAbstractItemView::mouseMoveEvent(QMouseEvent *event)。
[override virtual protected]
void QHeaderView::mousePressEvent(QMouseEvent *e)
再実装:QAbstractItemView::mousePressEvent(QMouseEvent *event)。
[override virtual protected]
void QHeaderView::mouseReleaseEvent(QMouseEvent *e)
再実装:QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)。
void QHeaderView::moveSection(int from, int to)
ビジュアルインデックスfrom にあるセクションをビジュアルインデックスto に移動します。
sectionsMoved()も参照 。
int QHeaderView::offset() const
ヘッダーのオフセットを返します: これはヘッダーの左端 (垂直ヘッダーの場合は上端) の可視ピクセルです。
setOffset()も参照ください 。
Qt::Orientation QHeaderView::orientation() const
ヘッダーの向きを返します。
Qt::Orientationも参照してください 。
[override virtual protected]
void QHeaderView::paintEvent(QPaintEvent *e)
再実装:QAbstractScrollArea::paintEvent(QPaintEvent *event)。
[virtual protected]
void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
与えられたpainter とrect を用いて、与えられたlogicalIndex で指定されたセクションを描画する。
通常、この関数を呼び出す必要はない。
[override virtual]
void QHeaderView::reset()
再インプリメント:QAbstractItemView::reset().
int QHeaderView::resizeContentsPrecision() const
QHeaderView がResizeToContents で計算する精度を返す。
setResizeContentsPrecision() およびsetSectionResizeMode()も参照 。
void QHeaderView::resizeSection(int logicalIndex, int size)
logicalIndex で指定されたセクションのサイズをピクセル単位でsize に変更する。sizeパラメータは0以上の値でなければならない。しかし、0に等しいサイズは推奨されない。そのような場合は、hideSection を代わりに使うべきである。
sectionResized()、sectionSize()、hideSection()も参照 。
[protected slot]
void QHeaderView::resizeSections()
サイズのヒントに従ってセクションのサイズを変更する。通常、この関数を呼び出す必要はない。
void QHeaderView::resizeSections(QHeaderView::ResizeMode mode)
現在のリサイズモードを無視して、与えられたmode に従ってセクションのサイズを変更します。
sectionResized()も参照 。
bool QHeaderView::restoreState(const QByteArray &state)
このヘッダービューのstate を復元する。この関数は、状態が復元された場合はtrue
を返し、そうでない場合は false を返します。
saveState()も参照してください 。
QByteArray QHeaderView::saveState() const
このヘッダ・ビューの現在の状態を保存します。
保存した状態を復元するには、戻り値をrestoreState() に渡す。
restoreState()も参照 。
[signal]
void QHeaderView::sectionClicked(int logicalIndex)
このシグナルはセクションがクリックされたときに発せられる。セクションの論理インデックスはlogicalIndex で指定する。
sectionPressed シグナルも発せられることに注意。
setSectionsClickable() およびsectionPressed()も参照 。
[signal]
void QHeaderView::sectionCountChanged(int oldCount, int newCount)
このシグナルは、セクション数が変更されたとき、つまりセクションが追加されたときや削除されたときに発せられる。元の数はoldCount で指定され、新しい数はnewCount で指定される。
count(),length(),headerDataChanged()も参照のこと 。
[signal]
void QHeaderView::sectionDoubleClicked(int logicalIndex)
このシグナルは、セクションがダブルクリックされたときに発せられる。セクションの論理インデックスはlogicalIndex で指定する。
setSectionsClickable()も参照のこと 。
[signal]
void QHeaderView::sectionEntered(int logicalIndex)
このシグナルは、カーソルがセクションの上に移動し、マウスの左ボタンが押されたときに発せられる。セクションの論理インデックスはlogicalIndex で指定する。
setSectionsClickable() およびsectionPressed()も参照のこと 。
[signal]
void QHeaderView::sectionHandleDoubleClicked(int logicalIndex)
このシグナルは、セクションがダブルクリックされたときに発せられる。セクションの論理インデックスはlogicalIndex で指定する。
setSectionsClickable()も参照のこと 。
[signal]
void QHeaderView::sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex)
このシグナルは、セクションが移動されたときに発せられる。セクションの論理インデックスはlogicalIndex で指定され、古いインデックスはoldVisualIndex で指定され、新しいインデックス位置はnewVisualIndex で指定される。
moveSection()も参照のこと 。
int QHeaderView::sectionPosition(int logicalIndex) const
指定されたlogicalIndex のセクションの位置を返し、セクションが非表示の場合は -1 を返す。位置は、最初に表示されるアイテムの左上隅から、logicalIndex を持つアイテムの左上隅までのピクセル単位で測定されます。水平方向のヘッダーの場合は x 軸に沿って、垂直方向のヘッダーの場合は y 軸に沿って測定されます。
sectionViewportPosition()も参照 。
[signal]
void QHeaderView::sectionPressed(int logicalIndex)
このシグナルはセクションが押されたときに発せられる。セクションの論理インデックスはlogicalIndex で指定する。
setSectionsClickable()も参照のこと 。
QHeaderView::ResizeMode QHeaderView::sectionResizeMode(int logicalIndex) const
与えられたlogicalIndex で指定されたセクションに適用されるリサイズモードを返します。
setSectionResizeMode()も参照 。
[signal]
void QHeaderView::sectionResized(int logicalIndex, int oldSize, int newSize)
このシグナルは、セクションのサイズが変更されたときに発せられる。セクションの論理番号はlogicalIndex で、古いサイズはoldSize で、新しいサイズはnewSize で指定される。
resizeSection()も参照のこと 。
int QHeaderView::sectionSize(int logicalIndex) const
与えられたlogicalIndex の幅 (垂直ヘッダの場合は高さ) を返す。
length()、setSectionResizeMode() およびdefaultSectionSize()も参照 ください。
[virtual protected]
QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const
与えられたlogicalIndex で指定されたセクションの内容のサイズを返す。
defaultSectionSize()も参照 。
int QHeaderView::sectionSizeHint(int logicalIndex) const
logicalIndex で指定されたセクションの適切なサイズのヒントを返す。
sizeHint()、defaultSectionSize()、minimumSectionSize()、maximumSectionSize()も参照のこと 。
int QHeaderView::sectionViewportPosition(int logicalIndex) const
与えられたlogicalIndex のセクションビューポート位置を返す。
セクションが非表示の場合、戻り値は未定義です。
sectionPosition() およびisSectionHidden()も参照 。
[protected slot]
void QHeaderView::sectionsAboutToBeRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast)
このスロットは、parent 。logicalFirst とlogicalLast は、セクションが削除された場所を示す。
セクションが1つだけ削除された場合、logicalFirst とlogicalLast は同じになる。
bool QHeaderView::sectionsClickable() const
sectionsClickable を返します。
メモ: sectionsClickable プロパティのゲッター関数です。
setSectionsClickable()も参照してください 。
bool QHeaderView::sectionsHidden() const
ヘッダ内のセクションが非表示になっている場合はtrue
を返し、そうでない場合は false を返す;
setSectionHidden()も参照 。
[protected slot]
void QHeaderView::sectionsInserted(const QModelIndex &parent, int logicalFirst, int logicalLast)
このスロットは、セクションがparent に挿入されるときに呼び出される。logicalFirst とlogicalLast のインデックスは、新しいセクションが挿入された場所を示す。
セクションが1つだけ挿入された場合、logicalFirst とlogicalLast は同じになる。
bool QHeaderView::sectionsMovable() const
sectionsMovable を返す。
メモ: sectionsMovable プロパティのゲッター関数。
setSectionsMovable()も参照してください 。
bool QHeaderView::sectionsMoved() const
ヘッダ内のセクションが移動した場合はtrue
を返し、そうでない場合は false を返す;
moveSection()も参照 。
[override virtual]
void QHeaderView::setModel(QAbstractItemModel *model)
再実装:QAbstractItemView::setModel(QAbstractItemModel *model).
[slot]
void QHeaderView::setOffset(int offset)
ヘッダーのオフセットをoffset に設定する。
[slot]
void QHeaderView::setOffsetToLastSection()
最後のセクションを表示するためのオフセットを設定します。
setOffset()、sectionPosition() およびsetOffsetToSectionPosition()も参照 。
[slot]
void QHeaderView::setOffsetToSectionPosition(int visualSectionNumber)
指定されたvisualSectionNumber のセクションの開始位置へのオフセットを設定します。visualSectionNumber は、hiddenSections を考慮しない場合の実際の可視セクションです。visualIndex() と同じとは限りません。
setOffset() およびsectionPosition()も参照 。
void QHeaderView::setResizeContentsPrecision(int precision)
ResizeToContents が使われたとき、QHeaderView がどの程度正確にサイズを計算するかを設定します。低い値は、正確ではないが高速な自動リサイズを提供し、高い値は、より正確なリサイズを提供するが、遅いかもしれない。
数値precision は、好ましいサイズを計算するときに考慮すべきセクションの数を指定します。
デフォルト値は1000で、これは自動リサイズを使用する横列が、自動リサイズを行う際に最大1000行を計算することを意味します。
特別な値0は、可視領域だけを見ることを意味します。特別な値-1は、すべての要素を見ることを意味します。
この値はQTableView::sizeHintForColumn(),QTableView::sizeHintForRow(),QTreeView::sizeHintForColumn() で使用される。これらの関数を再実装すると、この関数が効かなくなることがある。
resizeContentsPrecision(),setSectionResizeMode(),resizeSections(),QTableView::sizeHintForColumn(),QTableView::sizeHintForRow(),QTreeView::sizeHintForColumn()も参照 。
void QHeaderView::setSectionHidden(int logicalIndex, bool hide)
hide がtrueの場合、logicalIndex で指定されたセクションは非表示になり、そうでない場合は表示される。
isSectionHidden() およびhiddenSectionCount()も参照のこと 。
void QHeaderView::setSectionResizeMode(QHeaderView::ResizeMode mode)
ヘッダーのサイズ変更に関する制約を、与えられたmode で記述された制約に設定します。
sectionResizeMode(),length(),sectionResized()も参照 。
void QHeaderView::setSectionResizeMode(int logicalIndex, QHeaderView::ResizeMode mode)
ヘッダー内のlogicalIndex で指定されたセクションのサイズを、与えられたmode で記述されたサイズに変更するための制約を設定する。論理インデックスは、この関数が呼び出された時点で存在していなければならない。
注: stretchLastSection プロパティが true に設定されている場合、最後のセクションに対してこの設定は無視されます。これは、QTreeView で提供される水平ヘッダーのデフォルトです。
setStretchLastSection() およびresizeContentsPrecision()も参照してください 。
void QHeaderView::setSectionsClickable(bool clickable)
sectionsClickable をclickable に設定する。
注: プロパティsectionsClickable に対するセッター関数。
sectionsClickable()も参照してください 。
void QHeaderView::setSectionsMovable(bool movable)
sectionsMovable をmovable に設定する。
注: プロパティsectionsMovable に対するセッター関数。
sectionsMovable()も参照してください 。
[override virtual protected]
void QHeaderView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)
再実装:QAbstractItemView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)。
指定されたflags に従って、与えられたrect 内のアイテムを選択します。
基底クラスの実装は何もしません。
void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order)
与えられたlogicalIndex で指定されたセクションのソートインジケータをorder で指定された方向に設定し、 ソートインジケータが表示されていた他のセクションからソートインジケータを取り除きます。
logicalIndex この場合、ソートインジケータは表示されず、モデルはソートされていない自然な順序に戻ります。すべてのモデルがこれをサポートしているわけではなく、この場合クラッシュする可能性があることに注意してください。
sortIndicatorSection() およびsortIndicatorOrder()も参照のこと 。
[override virtual]
void QHeaderView::setVisible(bool v)
void QHeaderView::showSection(int logicalIndex)
logicalIndex で指定されたセクションを表示する。
hideSection()、isSectionHidden()、hiddenSectionCount()、setSectionHidden()も参照のこと 。
[override virtual]
QSize QHeaderView::sizeHint() const
再実装:QAbstractScrollArea::sizeHint() const.
このヘッダに適したサイズのヒントを返します。
sectionSizeHint()も参照ください 。
[signal]
void QHeaderView::sortIndicatorChanged(int logicalIndex, Qt::SortOrder order)
このシグナルは、ソートインジケータを含むセクションや、指示された順序が変更されたときに発せられる。セクションの論理インデックスはlogicalIndex で指定され、ソート順はorder で指定される。
setSortIndicator()も参照のこと 。
Qt::SortOrder QHeaderView::sortIndicatorOrder() const
ソートインジケータの並び順を返す。どのセクションにもソートインジケータがない場合、この関数の返り値は未定義である。
setSortIndicator() およびsortIndicatorSection()も参照 。
int QHeaderView::sortIndicatorSection() const
ソートインジケータを持つセクションの論理インデックスを返します。デフォルトでは、これはセクション 0 である。
setSortIndicator()、sortIndicatorOrder()、setSortIndicatorShown()も参照 。
int QHeaderView::stretchSectionCount() const
リサイズモードストレッチに設定されているセクションの数を返します。ビューでは、ビューのジオメトリが変更されたときに、ヘッダービューがセクションのサイズを変更する必要があるかどうかを確認するために使用できます。
stretchLastSectionも参照してください 。
void QHeaderView::swapSections(int first, int second)
ビジュアルインデックスfirst のセクションを、ビジュアルインデックスsecond のセクションと入れ替えます。
moveSection()も参照のこと 。
[override virtual protected]
int QHeaderView::verticalOffset() const
再実装:QAbstractItemView::verticalOffset() const.
ヘッダの垂直オフセットを返します。水平ヘッダの場合は 0。
offset()も参照ください 。
[override virtual protected]
bool QHeaderView::viewportEvent(QEvent *e)
再実装:QAbstractItemView::viewportEvent(QEvent *event)。
int QHeaderView::visualIndex(int logicalIndex) const
与えられたlogicalIndex で指定されたセクションのビジュアルインデックスの位置を返します。
非表示のセクションも有効なビジュアルインデックスを持ちます。
logicalIndex()も参照 。
int QHeaderView::visualIndexAt(int position) const
ビューポート内の指定されたposition をカバーするセクションのビジュアルインデックスを返す。
logicalIndexAt()も参照 。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.