TabBar QML Type
ユーザーが異なるビューやサブタスクを切り替えられるようにします。詳細...
Import Statement: | import QtQuick.Controls |
Inherits: |
プロパティ
- contentHeight : real
(since QtQuick.Controls 2.2 (Qt 5.9))
- contentWidth : real
(since QtQuick.Controls 2.2 (Qt 5.9))
- position : enumeration
付属物件
- index : int
(since QtQuick.Controls 2.3 (Qt 5.10))
- position : enumeration
(since QtQuick.Controls 2.3 (Qt 5.10))
- tabBar : TabBar
(since QtQuick.Controls 2.3 (Qt 5.10))
詳細説明
TabBar はタブベースのナビゲーションモデルを提供します。
TabBar にはTabButton コントロールが配置され、StackLayout やcurrentIndex
などの - プロパティを提供するレイアウトやコンテナ・コントロールと共に使用することができます。SwipeView
TabBar { id: bar width: parent.width TabButton { text: qsTr("Home") } TabButton { text: qsTr("Discover") } TabButton { text: qsTr("Activity") } } StackLayout { width: parent.width currentIndex: bar.currentIndex Item { id: homeTab } Item { id: discoverTab } Item { id: activityTab } }
上に示したように、TabBarには通常、タブ・バーの子としてインラインで定義される静的なタブ・ボタンが配置されます。また、add 、insert 、move 、remove の項目を実行時に動的に設定することも可能です。これらのアイテムには、itemAt() またはcontentChildren を使用してアクセスできます。
TabBarをSwipeView のような他のコンテナと組み合わせる場合、各コントロールのcurrentIndex プロパティ間で双方向バインディングを行う必要があります。バインディングを壊さずにこれを行うには、currentIndex
を直接設定するのを避け、代わりにsetCurrentIndex() などを使用します。詳しくはManaging the Current Index を参照してください。
currentIndex
が変更されたときにアクションを実行するには、onCurrentIndexChanged
プロパティ変更シグナル・ハンドラを使用します:
onCurrentIndexChanged: { print("currentIndex changed to", currentIndex) // ... }
タブのサイズ変更
デフォルトでは、TabBarはコントロールの幅に合わせてボタンのサイズを変更します。利用可能なスペースは、各ボタンに均等に配分されます。ボタンの幅を明示的に設定することで、デフォルトのリサイズ動作をオーバーライドすることができます。
次の例では、タブバーのサイズに合わせてリサイズする代わりに、各タブ・ボタンを暗黙のサイズに保つ方法を示します:
TabBar { width: parent.width TabButton { text: "First" width: implicitWidth } TabButton { text: "Second" width: implicitWidth } TabButton { text: "Third" width: implicitWidth } }
フリック可能なタブ
ボタンの幅の合計がタブバーの利用可能な幅を超えると、自動的にフリック可能になります。
TabBar { id: bar width: parent.width Repeater { model: ["First", "Second", "Third", "Fourth", "Fifth"] TabButton { text: modelData width: Math.max(100, bar.width / 5) } } }
TabButton 、タブバーのカスタマイズ、ナビゲーション・コントロール、コンテナ・コントロール、 Qt Quick Controls のフォーカス管理も参照してください 。
プロパティの説明
contentHeight : real |
このプロパティは、コンテンツの高さを保持します。このプロパティは、タブバーの暗黙的な高さの合計を計算するために使用されます。
注: このプロパティは、QtQuick.Controls 2.2 (Qt 5.9) 以降TabBar で使用できますが、QtQuick.Controls 2.5 (Qt 5.12) で Container 基本型に昇格しました。
このプロパティは QtQuick.Controls 2.2 (Qt 5.9) で導入されました。
Container::contentHeightも参照してください 。
contentWidth : real |
このプロパティは、コンテンツの幅を保持します。このプロパティは、タブバーの暗黙的な幅の合計を計算するために使用されます。
注: このプロパティは、QtQuick.Controls 2.2 (Qt 5.9) 以降TabBar で使用できますが、QtQuick.Controls 2.5 (Qt 5.12) で Container 基本型に昇格しました。
このプロパティは QtQuick.Controls 2.2 (Qt 5.9) で導入されました。
Container::contentWidthも参照してください 。
position : enumeration |
このプロパティは、タブバーの位置を保持します。
注: タブバーがApplicationWindow またはPage のヘッダーまたはフッターとして割り当てられている場合、適切な位置が自動的に設定されます。
可能な値:
定数 | 説明 |
---|---|
TabBar.Header | タブバーはウィンドウまたはページのヘッダーとして一番上にあります。 |
TabBar.Footer | タブバーは、ウィンドウまたはページのフッターとして、一番下にあります。 |
デフォルト値はスタイル固有です。
ApplicationWindow::header,ApplicationWindow::footer,Page::header, およびPage::footerも参照してください 。
付属プロパティ文書
TabBar.index : int |
TabBar.position : enumeration |
このアタッチされたプロパティは、タブバーの位置を保持します。
このプロパティは、TabBar の各タブボタンにアタッチされます。
可能な値
定数 | 説明 |
---|---|
TabBar.Header | タブバーはウィンドウまたはページのヘッダーとして上部にあります。 |
TabBar.Footer | タブバーは、ウィンドウまたはページのフッターとして、一番下にあります。 |
このプロパティは QtQuick.Controls 2.3 (Qt 5.10) で導入されました。
TabBar.tabBar : TabBar |
このアタッチされたプロパティは、このタブボタンを管理するタブバーを保持します。
このプロパティは、TabBar の各タブボタンにアタッチされます。
このプロパティは QtQuick.Controls 2.3 (Qt 5.10) で導入されました。
© 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.