導覽
SelectorBar 選擇列
一列可選取的項目,用於在不同檢視間切換。
範例
屬性預覽載入失敗。請再次點選屬性預覽重試。

用法
搭配承載頁面的 SelectorBar
使用 addItem() 加入項目,並處理 currentChanged 或 selectionChanged 以切換頁面或篩選條件。
#include <FluentQt/Navigation.h>
using namespace fluent::navigation;
auto* selector = new SelectorBar(this);
selector->addItem(SelectorBarItem("Inbox", Typography::Icons::Mail,
true, true, "inbox"));
selector->addItem(SelectorBarItem("Calendar", Typography::Icons::Calendar,
true, true, "calendar"));
selector->addItem(SelectorBarItem("Settings", Typography::Icons::Settings,
true, true, "settings"));
auto* host = new StackContentHost(this);
for (int i = 0; i < selector->itemCount(); ++i)
host->insertPage(i, createPage(selector->itemAt(i).text));
connect(selector, &SelectorBar::currentChanged,
host, [host](int index) { host->setCurrentIndex(index, 0, true); });
connect(selector, &SelectorBar::selectionChanged,
this, [](int, const SelectorBarItem& item) {
const auto key = item.data.toString();
});import fluentqt
selector = fluentqt.SelectorBar()
selector.addItem(
fluentqt.SelectorBarItem(
"Inbox",
fluentqt.Typography.Icons.Mail,
True,
True,
"inbox"
)
)
selector.addItem(
fluentqt.SelectorBarItem(
"Calendar",
fluentqt.Typography.Icons.Calendar,
True,
True,
"calendar"
)
)
selector.addItem(
fluentqt.SelectorBarItem(
"Settings",
fluentqt.Typography.Icons.Settings,
True,
True,
"settings"
)
)
host = fluentqt.StackContentHost()
for index in range(selector.itemCount()):
host.insertOwnedPage(index, create_page(selector.itemAt(index).text))
selector.currentChanged.connect(lambda index: host.setCurrentIndex(index, 0, True))
selector.selectionChanged.connect(lambda _index, item: item.data)API
檢視宣告沒有符合的 API 成員。