基本入力
CheckBox チェックボックス
オプションを選択または解除します。混合状態は一部の項目のみが選択されていることを示します。
サンプル
プロパティプレビューを読み込めませんでした。もう一度「プロパティプレビュー」を選択して再試行してください。






使い方
変更への応答
チェックのオン/オフ時に応答するには、toggled または stateChanged を接続します。
#include <FluentQt/BasicInput.h>
using namespace fluent::basicinput;
auto* checkBox = new CheckBox("Accept terms", this);
auto* status = new Label("State: Unchecked", this);
connect(checkBox, &CheckBox::stateChanged, status, [status](int state) {
status->setText(state == Qt::Checked ? "State: Checked" : "State: Unchecked");
});
auto* disabledOff = new CheckBox("Disabled off", this);
disabledOff->setEnabled(false);
auto* disabledOn = new CheckBox("Disabled on", this);
disabledOn->setChecked(true);
disabledOn->setEnabled(false);import fluentqt
from PySide6.QtCore import Qt
check_box = fluentqt.CheckBox("Accept terms")
status = fluentqt.Label("State: Unchecked")
check_box.stateChanged.connect(
lambda state: status.setText(
"State: Checked"
if Qt.CheckState(state) == Qt.CheckState.Checked
else "State: Unchecked"
)
)
disabled_off = fluentqt.CheckBox("Disabled off")
disabled_off.setEnabled(False)
disabled_on = fluentqt.CheckBox("Disabled on")
disabled_on.setChecked(True)
disabled_on.setEnabled(False)混合状態
setTristate(true) を呼び出し、一部の項目のみが選択されている場合に Qt::PartiallyChecked を使用します。
#include <FluentQt/BasicInput.h>
using namespace fluent::basicinput;
auto* checkBox = new CheckBox("Enable selected items", this);
checkBox->setTristate(true);
checkBox->setCheckState(Qt::PartiallyChecked);
auto* status = new Label("State: Mixed", this);
connect(checkBox, &CheckBox::stateChanged, status, [status](int state) {
status->setText(state == Qt::Checked ? "State: Checked"
: state == Qt::PartiallyChecked
? "State: Mixed"
: "State: Unchecked");
});import fluentqt
from PySide6.QtCore import Qt
check_box = fluentqt.CheckBox("Enable selected items")
check_box.setTristate(True)
check_box.setCheckState(Qt.CheckState.PartiallyChecked)
status = fluentqt.Label("State: Mixed")
check_box.stateChanged.connect(
lambda state: status.setText(
"State: Checked"
if Qt.CheckState(state) == Qt.CheckState.Checked
else "State: Mixed"
if Qt.CheckState(state) == Qt.CheckState.PartiallyChecked
else "State: Unchecked"
)
)すべて選択
親チェックボックスは子項目の状態に合わせて Checked、Unchecked、または PartiallyChecked を表示します。
#include <FluentQt/BasicInput.h>
using namespace fluent::basicinput;
auto* selectAll = new CheckBox("Select all", this);
selectAll->setTristate(true);
auto* mail = new CheckBox("Mail", this);
auto* calendar = new CheckBox("Calendar", this);
auto* people = new CheckBox("People", this);
auto updateSelectAll = [=]() {
const int checked = int(mail->isChecked()) + int(calendar->isChecked()) + int(people->isChecked());
selectAll->setCheckState(checked == 0 ? Qt::Unchecked : checked == 3 ? Qt::Checked : Qt::PartiallyChecked);
};
connect(selectAll, &CheckBox::clicked, this, [=]() {
const bool checked = selectAll->checkState() == Qt::Checked;
mail->setChecked(checked);
calendar->setChecked(checked);
people->setChecked(checked);
});
connect(mail, &CheckBox::clicked, this, updateSelectAll);
connect(calendar, &CheckBox::clicked, this, updateSelectAll);
connect(people, &CheckBox::clicked, this, updateSelectAll);import fluentqt
from PySide6.QtCore import Qt
select_all = fluentqt.CheckBox("Select all")
select_all.setTristate(True)
mail = fluentqt.CheckBox("Mail")
calendar = fluentqt.CheckBox("Calendar")
people = fluentqt.CheckBox("People")
def update_select_all():
checked = sum(item.isChecked() for item in (mail, calendar, people))
state = (
Qt.CheckState.Unchecked if checked == 0
else Qt.CheckState.Checked if checked == 3
else Qt.CheckState.PartiallyChecked
)
select_all.setCheckState(state)
def apply_select_all():
checked = select_all.checkState() == Qt.CheckState.Checked
mail.setChecked(checked)
calendar.setChecked(checked)
people.setChecked(checked)
select_all.clicked.connect(apply_select_all)
mail.clicked.connect(update_select_all)
calendar.clicked.connect(update_select_all)
people.clicked.connect(update_select_all)API
宣言を表示一致する API メンバーはありません。
fluent::basicinput::CheckBox
継承元 QCheckBox · FluentElement · QMLPlus
チェック状態と中間状態のアニメーションを備えた Fluent チェックボックス。
コンストラクタ
メソッド
qreal checkProgress() const正規化されたチェック状態アニメーションの進捗。
void setCheckProgress(qreal progress)正規化されたチェック状態アニメーションの進捗。
int boxSize() constチェックボックスのボックスサイズ(ピクセル単位)。
void setBoxSize(int size)チェックボックスのボックスサイズ(ピクセル単位)。
int boxMargin() constチェックボックスの枠手前の先頭マージン。
void setBoxMargin(int margin)チェックボックスの枠手前の先頭マージン。
int textGap() constコントロールグリフとテキストコンテンツ間の間隔。
void setTextGap(int gap)コントロールグリフとテキストコンテンツ間の間隔。
bool hoverBackgroundEnabled() constホバー時に控えめな行背景を描画するかどうか。
void setHoverBackgroundEnabled(bool enabled)ホバー時に控えめな行背景を描画するかどうか。
プロパティ
qreal checkProgress正規化されたチェック状態アニメーションの進捗。
読み取りcheckProgress()書き込みsetCheckProgress()int boxSizeチェックボックスのボックスサイズ(ピクセル単位)。
読み取りboxSize()書き込みsetBoxSize()通知シグナルboxSizeChanged()int boxMarginチェックボックスの枠手前の先頭マージン。
読み取りboxMargin()書き込みsetBoxMargin()通知シグナルboxMarginChanged()int textGapコントロールグリフとテキストコンテンツ間の間隔。
読み取りtextGap()書き込みsetTextGap()通知シグナルtextGapChanged()bool hoverBackgroundEnabledホバー時に控えめな行背景を描画するかどうか。
読み取りhoverBackgroundEnabled()書き込みsetHoverBackgroundEnabled()通知シグナルhoverBackgroundEnabledChanged()
シグナル
void boxSizeChanged()チェックボックスのボックスサイズ(ピクセル単位)。
void boxMarginChanged()チェックボックスの枠手前の先頭マージン。
void textGapChanged()コントロールグリフとテキストコンテンツ間の間隔。
void hoverBackgroundEnabledChanged()ホバー時に控えめな行背景を描画するかどうか。
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 基底クラスドキュメント:QCheckBox