選單與工具列
CommandPalette 命令選擇區
輸入名稱即可搜尋並執行動作。可使用鍵盤選擇結果並按下 Enter 執行。
範例
屬性預覽載入失敗。請再次點選屬性預覽重試。

用法
搜尋並執行命令
搜尋頁面名稱,使用方向鍵選擇,再按下 Enter 執行。按下 Escape 可關閉面板。
#include <FluentQt/MenusToolbars.h>
using namespace fluent::menus_toolbars;
auto* layout = new QVBoxLayout(this);
auto* location = new Label(QStringLiteral("Current page: Home"), this);
auto* palette = new fluent::menus_toolbars::CommandPalette(this);
palette->setPlaceholderText(QStringLiteral("Search pages..."));
palette->setDim(true);
palette->setDimOpacity(0.12);
const QStringList pages{QStringLiteral("Home"), QStringLiteral("Inbox"),
QStringLiteral("Documents"), QStringLiteral("Folders")};
for (const QString& page : pages) {
auto* action = new QAction(page, this);
palette->addCommand(action, QStringLiteral("Navigation"));
QObject::connect(action, &QAction::triggered, location, [location, page] {
location->setText(QStringLiteral("Current page: %1").arg(page));
});
}
auto* open = new Button(QStringLiteral("Search pages"), this);
open->setFluentStyle(Button::Accent);
open->setIconGlyph(Typography::Icons::Search);
QObject::connect(open, &Button::clicked, palette, &fluent::menus_toolbars::CommandPalette::open);
layout->addWidget(open, 0, Qt::AlignLeft);
layout->addWidget(location);import fluentqt
from PySide6.QtCore import Qt
from PySide6.QtGui import QAction
from PySide6.QtWidgets import QVBoxLayout
layout = QVBoxLayout(window)
location = fluentqt.Label("Current page: Home", window)
palette = fluentqt.CommandPalette(window)
palette.setPlaceholderText("Search pages...")
palette.setDim(True)
palette.setDimOpacity(0.12)
for page in ("Home", "Inbox", "Documents", "Folders"):
action = QAction(page, window)
palette.addCommand(action, "Navigation")
action.triggered.connect(
lambda checked=False, name=page: location.setText(f"Current page: {name}")
)
open_button = fluentqt.Button("Search pages", window)
open_button.setFluentStyle(fluentqt.Button.ButtonStyle.Accent)
open_button.setIconGlyph(fluentqt.Typography.Icons.Search)
open_button.clicked.connect(palette.open)
layout.addWidget(open_button, 0, Qt.AlignmentFlag.AlignLeft)
layout.addWidget(location)API
檢視宣告沒有符合的 API 成員。