コレクション
ListView リストビュー
選択可能なインタラクティブ項目の縦方向リストを表示します。
サンプル
プロパティプレビューを読み込めませんでした。もう一度「プロパティプレビュー」を選択して再試行してください。

使い方
アバター付き ListView
各行はアバターとテキストの組み合わせで構成され、選択するとアニメーション付きのインジケーターが表示されます。
#include <FluentQt/Collections.h>
using namespace fluent::collections;
auto* listView = new ListView(this);
listView->setBackgroundVisible(false);
listView->setBorderVisible(false);
listView->setProperty("fluentPreserveParentSurface", true);
listView->viewport()->setProperty(
"fluentPreserveParentSurface", true);
listView->setFixedSize(320, 234);
listView->setHeaderText("Contacts");
listView->setAccessibleName("Contacts");
listView->setIconSize(QSize(28, 28));
auto* model = new QStandardItemModel(listView);
const QStringList contacts{
"Kendall Collins", "Henry Ross", "Nicole Wagner",
"Adam Wolfe", "Stephanie Meyer", "Maya Patel",
"Alex Chen", "Priya Shah", "Omar Rivera",
"Elena Rossi", "Jordan Lee", "Riley Brooks"};
int colorIndex = 0;
for (const QString& contact : contacts) {
auto* item = new QStandardItem(contact);
item->setEditable(false);
item->setData(initialsAvatar(
contact, accentPalette().at(
colorIndex++ % accentPalette().size())),
Qt::DecorationRole);
model->appendRow(item);
}
listView->setModel(model);
listView->setSelectedIndex(0);import fluentqt
from PySide6.QtCore import QRectF, QSize, Qt
from PySide6.QtGui import (
QColor,
QFont,
QGuiApplication,
QPainter,
QPixmap,
QStandardItem,
QStandardItemModel,
)
def make_initials_avatar(name, background, size=28):
screen = QGuiApplication.primaryScreen()
dpr = max(1.0, screen.devicePixelRatio() if screen is not None else 1.0)
physical = max(1, round(size * dpr))
pixmap = QPixmap(physical, physical)
pixmap.setDevicePixelRatio(dpr)
pixmap.fill(Qt.GlobalColor.transparent)
painter = QPainter(pixmap)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(background)
tile = QRectF(0, 0, size, size)
painter.drawEllipse(tile)
font = QFont()
font.setPixelSize(round(size * 0.42))
font.setWeight(QFont.Weight.DemiBold)
painter.setFont(font)
painter.setPen(Qt.GlobalColor.white)
initials = "".join(word[0].upper() for word in name.split()[:2])
painter.drawText(tile, Qt.AlignmentFlag.AlignCenter, initials)
painter.end()
return pixmap
accent_palette = (
QColor(0x00, 0x78, 0xD4), QColor(0x03, 0x83, 0x87),
QColor(0xCA, 0x50, 0x10), QColor(0x87, 0x64, 0xB8),
QColor(0xC2, 0x39, 0xB3), QColor(0x49, 0x82, 0x05),
)
list_view = fluentqt.ListView()
list_view.setBackgroundVisible(False)
list_view.setBorderVisible(False)
list_view.setProperty("fluentPreserveParentSurface", True)
list_view.viewport().setProperty(
"fluentPreserveParentSurface",
True
)
list_view.setFixedSize(320, 234)
list_view.setHeaderText("Contacts")
list_view.setAccessibleName("Contacts")
list_view.setIconSize(QSize(28, 28))
model = QStandardItemModel(list_view)
contacts = (
"Kendall Collins", "Henry Ross", "Nicole Wagner",
"Adam Wolfe", "Stephanie Meyer", "Maya Patel",
"Alex Chen", "Priya Shah", "Omar Rivera",
"Elena Rossi", "Jordan Lee", "Riley Brooks",
)
for index, contact in enumerate(contacts):
item = QStandardItem(contact)
item.setEditable(False)
item.setData(
make_initials_avatar(contact, accent_palette[index % len(accent_palette)]),
Qt.ItemDataRole.DecorationRole
)
model.appendRow(item)
list_view.setModel(model)
list_view.setSelectedIndex(0)API
宣言を表示一致する API メンバーはありません。
fluent::collections::ListView
継承元 QListView · FluentElement · QMLPlus
ヘッダー/フッタースロット、セクショングループ化、アニメーション付き選択インジケーターを備えた Fluent リストビューです。Qt のアイテムモデルとデリゲートを使用し、Fluent の選択スタイル、プレースホルダーテキスト、ドラッグによる並べ替えを提供します。
コンストラクタ
デストラクタ
列挙型
enum class IndicatorMotionDirectionNoneUpDownLeftRight
メソッド
Flow flow() constアイテムの配置方向(TopToBottom または LeftToRight)。
void setFlow(Flow flow)アイテムの配置方向(TopToBottom または LeftToRight)。
SelectionMode selectionMode() constコレクションビューで使用される選択モードです。
void setSelectionMode(SelectionMode mode)コレクションビューで使用される選択モードです。
Typography::FontRole fontRole() constテキスト描画に使用される Fluent タイポグラフィロール。
void setFontRole(Typography::FontRole role)テキスト描画に使用される Fluent タイポグラフィロール。
int trailingTextRole() const末尾の補助テキスト用のオプションのモデルロール。-1 を指定すると非表示になります。
void setTrailingTextRole(int role)デフォルトデリゲートが末尾テキストに使用するロールを設定します。カスタムデリゲートは独自のレイアウトを処理します。
bool borderVisible() constコントロールの枠線を描画するかどうか。
void setBorderVisible(bool visible)コントロールの枠線を描画するかどうか。
bool backgroundVisible() constコントロールの背景を描画するかどうか。
void setBackgroundVisible(bool visible)コントロールの背景を描画するかどうか。
QWidget* header() constListView のヘッダー領域にホストされるカスタムウィジェット。
void setHeader(QWidget* widget)ListView のヘッダー領域にホストされるカスタムウィジェット。
QString headerText() constヘッダー領域に表示される簡易テキスト。
void setHeaderText(const QString& text)ヘッダー領域に表示される簡易テキスト。
QString placeholderText() constモデルに項目がないときに表示されるテキストです。
void setPlaceholderText(const QString& text)モデルに項目がないときに表示されるテキストです。
bool viewportHovered() constビューポートが現在ホバーされているかどうか。
bool canReorderItems() constドラッグによる並べ替えが有効かどうかです。
void setCanReorderItems(bool enabled)ドラッグによる並べ替えが有効かどうかです。
bool isScrollChainingEnabled() constスクロール境界でのホイール入力を外側のスクローラーへ引き継ぐかどうかです。
void setScrollChainingEnabled(bool enabled)スクロール境界でのホイール入力を外側のスクローラーへ引き継ぐかどうかです。
bool sectionEnabled() constセクションキーコールバックを使用して、隣接する項目をセクションヘッダー配下にグループ化するかどうかです。
void setSectionEnabled(bool enabled)セクションキーコールバックを使用して、隣接する項目をセクションヘッダー配下にグループ化するかどうかです。
void setSectionKeyFunction(SectionKeyFunc func)行ごとにセクションキーを返すコールバックを設定します。同じキーを持つ連続した行はセクションヘッダーを共有します。
qreal selectedIndicatorProgress() const選択項目インジケーターのアニメーション進捗。
IndicatorMotionDirection selectedIndicatorMotionDirection() const選択インジケーターのモーションで使用される方向。
bool selectedIndicatorAnimationEnabled() const選択インジケーターが行間をアニメーション移動するかどうか。無効にすると、ターゲット矩形へ即座にスナップします。
void setSelectedIndicatorAnimationEnabled(bool enabled)選択インジケーターのアニメーションを有効にするかどうか。
bool selectionIndicatorVisible() const選択項目インジケーターを描画するかどうか。
void setSelectionIndicatorVisible(bool visible)選択動作に影響を与えずに、選択インジケーターを表示または非表示にします。
QRectF selectedIndicatorRect() constビューポート座標系における現在の選択インジケーター矩形を返します。表示されているものがない場合は空の矩形を返します。
QRectF selectedIndicatorRect(qreal progress) const[0, 1] の正規化されたアニメーション進行度における選択インジケーター矩形を返します。
QRectF selectedIndicatorRectForRow(int row) const特定の行の選択インジケーター矩形を返します(複数選択モードで使用されます)。
void refreshFluentScrollChrome()ネイティブスクロールバーを非表示にし、Fluent オーバーレイスクロールバーを更新します。QComboBox のポップアップ内などで表示後にプラットフォームスタイルがネイティブバーを復元する場合は、再度呼び出してください。
プロパティ
SelectionMode selectionModeコレクションビューで使用される選択モードです。
読み取りselectionMode()書き込みsetSelectionMode()通知シグナルselectionModeChanged()Typography::FontRole fontRoleテキスト描画に使用される Fluent タイポグラフィロール。
読み取りfontRole()書き込みsetFontRole()通知シグナルfontRoleChanged()int trailingTextRole末尾の補助テキスト用のオプションのモデルロール。-1 を指定すると非表示になります。
読み取りtrailingTextRole()書き込みsetTrailingTextRole()通知シグナルtrailingTextRoleChanged()bool viewportHoveredビューポートが現在ホバーされているかどうか。
読み取りviewportHovered()通知シグナルviewportHoveredChanged()Flow flowアイテムの配置方向(TopToBottom または LeftToRight)。
読み取りflow()書き込みsetFlow()通知シグナルflowChanged()qreal selectedIndicatorProgress選択項目インジケーターのアニメーション進捗。
読み取りselectedIndicatorProgress()通知シグナルselectedIndicatorProgressChanged()IndicatorMotionDirection selectedIndicatorMotionDirection選択インジケーターのモーションで使用される方向。
読み取りselectedIndicatorMotionDirection()通知シグナルselectedIndicatorMotionDirectionChanged()bool selectedIndicatorAnimationEnabled選択インジケーターのアニメーションを有効にするかどうか。
読み取りselectedIndicatorAnimationEnabled()書き込みsetSelectedIndicatorAnimationEnabled()通知シグナルselectedIndicatorAnimationEnabledChanged()bool selectionIndicatorVisible選択項目インジケーターを描画するかどうか。
読み取りselectionIndicatorVisible()書き込みsetSelectionIndicatorVisible()通知シグナルselectionIndicatorVisibleChanged()bool borderVisibleコントロールの枠線を描画するかどうか。
読み取りborderVisible()書き込みsetBorderVisible()通知シグナルborderVisibleChanged()bool backgroundVisibleコントロールの背景を描画するかどうか。
読み取りbackgroundVisible()書き込みsetBackgroundVisible()通知シグナルbackgroundVisibleChanged()QWidget* headerListView のヘッダー領域にホストされるカスタムウィジェット。
読み取りheader()書き込みsetHeader()通知シグナルheaderChanged()QString headerTextヘッダー領域に表示される簡易テキスト。
読み取りheaderText()書き込みsetHeaderText()通知シグナルheaderTextChanged()QString placeholderTextモデルに項目がないときに表示されるテキストです。
読み取りplaceholderText()書き込みsetPlaceholderText()通知シグナルplaceholderTextChanged()bool canReorderItemsドラッグによる並べ替えが有効かどうかです。
読み取りcanReorderItems()書き込みsetCanReorderItems()通知シグナルcanReorderItemsChanged()bool scrollChainingEnabledスクロール境界でのホイール入力を外側のスクローラーへ引き継ぐかどうかです。
読み取りisScrollChainingEnabled()書き込みsetScrollChainingEnabled()通知シグナルscrollChainingEnabledChanged()bool sectionEnabledセクションキーコールバックを使用して、隣接する項目をセクションヘッダー配下にグループ化するかどうかです。
読み取りsectionEnabled()書き込みsetSectionEnabled()通知シグナルsectionEnabledChanged()
シグナル
void selectionModeChanged()コレクションビューで使用される選択モードです。
void fontRoleChanged()テキスト描画に使用される Fluent タイポグラフィロール。
void trailingTextRoleChanged()末尾の補助テキスト用のオプションのモデルロール。-1 を指定すると非表示になります。
void viewportHoveredChanged()ビューポートが現在ホバーされているかどうか。
void flowChanged()アイテムの配置方向(TopToBottom または LeftToRight)。
void borderVisibleChanged()コントロールの枠線を描画するかどうか。
void backgroundVisibleChanged()コントロールの背景を描画するかどうか。
void headerChanged()ListView のヘッダー領域にホストされるカスタムウィジェット。
void headerTextChanged()ヘッダー領域に表示される簡易テキスト。
void placeholderTextChanged()モデルに項目がないときに表示されるテキストです。
void canReorderItemsChanged()ドラッグによる並べ替えが有効かどうかです。
void scrollChainingEnabledChanged()スクロール境界でのホイール入力を外側のスクローラーへ引き継ぐかどうかです。
void sectionEnabledChanged()セクションキーコールバックを使用して、隣接する項目をセクションヘッダー配下にグループ化するかどうかです。
void selectedIndicatorProgressChanged()選択項目インジケーターのアニメーション進捗。
void selectedIndicatorMotionDirectionChanged()選択インジケーターのモーションで使用される方向。
void selectedIndicatorAnimationEnabledChanged()選択インジケーターのアニメーションを有効にするかどうか。
void selectionIndicatorVisibleChanged()選択項目インジケーターを描画するかどうか。
void itemClicked(int index)QAbstractItemView::clicked() と併せて、クリックされた行インデックスを送出する便利なシグナル。
型とエイリアス
PySide6 拡張
protected メンバー
メソッド
fluent::FluentElement から継承
列挙型
enum Themeデザイントークン解決時に使用されるグローバルな視覚テーマ。
Light = 0Dark = 1HighContrast = 2
メソッド
static void setTheme(Theme theme)グローバルテーマを更新し、アクティブな FluentElement インスタンスに通知します。
static void setThemeDeferred(Theme theme)現在の操作をブロックせずに、可視要素を優先したバッチ処理でテーマの更新をスケジュールします。
static Theme currentTheme()現在有効なグローバルテーマを返します。
static bool themeUsesDarkAppearance(Theme theme)テーマがダークベースのクロームおよびマテリアルトークンを使用するかどうかを返します。
static void refreshTheme()デザイントークンの変更後に再描画するため、現在のテーマを再ブロードキャストします。
static int themeGeneration()テーマ変更ごとに加算される単調増加カウンターです。鮮度チェックに使用されます。
Theme effectiveTheme() const継承された QWidget の上書きを尊重し、この要素が使用するテーマを解決します。
bool effectiveThemeUsesDarkAppearance() constこの要素の有効なテーマがダークベースのクロームを使用するかどうかを返します。
bool setThemeOverrides(const QJsonObject& overrides)この要素のスパースな色、角丸半径、フォントトークンの上書きを置き換えます。
QJsonObject themeOverrides() constこの要素に設定されたオーバーライドを返します。
void clearThemeOverrides()すべてのトークンフィールドをグローバルテーマの既定値に復元します。
const Colors& themeColorsRef() const描画のホットパス向けにアクティブなカラーセットへ非コピーでアクセスします。
Material::AcrylicToken themeAcrylic() constマテリアル、エレベーション、およびアダプティブレイアウトのトークン。
QColor themeBackdrop(bool active) const指定されたアクティブ状態に対するウィンドウ chrome の背景色。
virtual void onThemeUpdated()グローバルテーマの変更後に呼び出されます。
型とエイリアス
struct Colorsコンポーネントに返されるデザイントークンのスナップショット。
fluent::QMLPlus から継承
メソッド
AnchorLayout::Anchors* anchors()QWidget ホストの変更可能なアンカーを返します。
void setState(const QString& name)登録済みの状態を名前で適用するか、@p name が空の場合はデフォルト状態を復元します。未知の名前は無視され、その状態を離れると既存のバインディングが再開されます。
void addState(const QMLState& state)名前付き状態定義を登録または置換します。アクティブな状態を置換した場合は即座に適用されます。
void evaluateStates()登録順に状態条件を再評価し、最初に一致した状態(一致しない場合はデフォルト状態)をアクティブにします。依存プロパティの変更通知時にも自動実行され、extend を使用する派生状態は、循環や欠損がない限り祖先の変更を継承します。
QMLPlusRuntime* runtime()このホストが所有し、遅延生成される状態オブザーバーを返します。
void setAnchors(const AnchorLayout::Anchors& anchors)すべてのホストアンカーを置き換え、親レイアウトを無効化します。
void resetAnchors()ホストのすべてのアンカーをクリアし、親レイアウトを無効化します。
void bind(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction dir = PropertyBinder::OneWay)PropertyBinder::bind() を介して、@p source の @p sourceProp をこの QWidget ホストの @p targetProp にバインドします。
BindingHandle bindManaged(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction direction = PropertyBinder::OneWay, BindingOptions options = {})この QWidget ホストに管理された直接バインディングを設定します。
BindingHandle bindComputed(const char* targetProp, const QVector<BindingDependency>& dependencies, std::function<QVariant()> evaluate, BindingOptions options = {})この QWidget ホストに明示的依存関係を持つ C++ 式を設定します。
void addTransition(const StateTransition& transition)優先順位順に状態遷移を登録します。
void setBehavior(const char* propertyName, const PropertyAnimation& animation)writeProperty() またはバインディング経由で @p propertyName が書き込まれた際に使用されるデフォルトアニメーションを設定します。明示的な StateTransition ルールが優先され、C++ のセッターを直接呼び出した場合はアニメーションしません。
void clearBehavior(const char* propertyName)今後のマネージド書き込みに使用するデフォルトアニメーションを削除します。
bool writeProperty(const char* propertyName, const QVariant& value)バインディングを削除せずに Behavior 経由でホストプロパティに書き込みます。
Qt 基底クラスドキュメント:QListView