テキスト入力
LineEdit 1行テキスト入力
Fluent スタイルとクリアボタンを備えた 1 行テキスト入力ボックスです。
サンプル
プロパティプレビューを読み込めませんでした。もう一度「プロパティプレビュー」を選択して再試行してください。

使い方
単位とインラインアクション
値を読みやすく保ちつつ補足情報や操作をすぐ近くに配置できます。setTrailingText() で単位を表示し、setTrailingWidget() でインラインアクションを追加できます。
#include <FluentQt/TextFields.h>
using namespace fluent::textfields;
auto* width = new LineEdit(this);
width->setAccessibleName("Canvas width");
width->setText("1280");
width->setTrailingText("px");
width->setClearButtonAccessibleName("Clear canvas width");
width->setClearButtonFocusPolicy(Qt::StrongFocus);
auto* name = new LineEdit(this);
name->setAccessibleName("Export name");
name->setText("gallery-preview-v2");
name->setClearButtonEnabled(false);
auto* reset = new Button("Reset");
reset->setFluentStyle(Button::Subtle);
reset->setFluentSize(Button::Small);
reset->setFontRole(Typography::FontRole::Caption);
auto actionFont = reset->font();
actionFont.setStyleName(QString());
actionFont.setWeight(QFont::DemiBold);
reset->setFont(actionFont);
reset->setTextColorRole(Button::TextColorRole::Accent);
reset->setFixedSize(Spacing::XXLarge, Spacing::ControlHeight::Small);
reset->setFocusVisual(true);
reset->setAccessibleName("Reset export name");
name->setTrailingWidget(reset, WidgetOwnership::Owned);
connect(reset, &Button::clicked, name, [name] {
name->setText("gallery-preview");
});import fluentqt
from PySide6.QtCore import Qt
from PySide6.QtGui import QFont
width_column = root.add_column()
name_column = root.add_column()
width = fluentqt.LineEdit(width_column)
width.setAccessibleName('Canvas width')
width.setText('1280')
width.setTrailingText('px')
width.setClearButtonAccessibleName('Clear canvas width')
width.setClearButtonFocusPolicy(Qt.StrongFocus)
name = fluentqt.LineEdit(name_column)
name.setAccessibleName('Export name')
name.setText('gallery-preview-v2')
name.setClearButtonEnabled(False)
reset = fluentqt.Button('Reset')
reset.setFluentStyle(fluentqt.Button.ButtonStyle.Subtle)
reset.setFluentSize(fluentqt.Button.ButtonSize.Small)
reset.setFontRole(fluentqt.FontRole.Caption)
action_font = reset.font()
action_font.setStyleName('')
action_font.setWeight(QFont.DemiBold)
reset.setFont(action_font)
reset.setTextColorRole(fluentqt.Button.TextColorRole.Accent)
reset.setFixedSize(fluentqt.Spacing.XXLarge, fluentqt.Spacing.ControlHeight.Small)
reset.setFocusVisual(True)
reset.setAccessibleName('Reset export name')
name.setTrailingWidget(reset, fluentqt.WidgetOwnership.Owned)
reset.clicked.connect(lambda: name.setText('gallery-preview'))API
宣言を表示一致する API メンバーはありません。
fluent::textfields::LineEdit
継承元 QLineEdit · FluentElement · QMLPlus
クリアボタン、フォーカス下線、末尾スロットを備えた Fluent 単一行テキスト入力です。QLineEdit をラップし、トークン駆動の余白、タイポグラフィ、枠線表示、境界線幅を提供します。
コンストラクタ
デストラクタ
メソッド
QMargins contentMargins() constテキスト周囲のコンテンツ余白(水平方向の値には Qt の内部テキストインセットが含まれます)。
void setContentMargins(const QMargins& margins)テキスト周囲のコンテンツ余白(水平方向の値には Qt の内部テキストインセットが含まれます)。
Typography::FontRole fontRole() constテキストに使用される Fluent Typography プリセット。
void setFontRole(Typography::FontRole role)テキストに使用される Fluent Typography プリセット。
bool isClearButtonEnabled() const末尾のクリアボタンを有効にするかどうか。
void setClearButtonEnabled(bool enabled)末尾のクリアボタンを有効にするかどうか。
int clearButtonSize() constクリアボタンのサイズ。既定値は 24 論理ピクセルです。
void setClearButtonSize(int size)クリアボタンのサイズ。既定値は 24 論理ピクセルです。
QPoint clearButtonOffset() constクリアボタンに適用されるピクセルオフセット。
void setClearButtonOffset(const QPoint& offset)クリアボタンに適用されるピクセルオフセット。
int focusedBorderWidth() constフォーカス時の下枠線の幅。
void setFocusedBorderWidth(int width)フォーカス時の下枠線の幅。
int unfocusedBorderWidth() const非フォーカス時の下枠線の幅。既定値は 0(下線なし)です。
void setUnfocusedBorderWidth(int width)非フォーカス時の下枠線の幅。既定値は 0(下線なし)です。
bool isFrameVisible() constLineEdit が入力枠とフォーカス下線を描画するかどうかです。
void setFrameVisible(bool visible)LineEdit が入力枠とフォーカス下線を描画するかどうかです。
void setTrailingText(const QString& text)末尾にプレーンテキストのサフィックスを表示し、既存の末尾ウィジェットを置き換えます。
bool setTrailingWidget(QWidget* widget, WidgetOwnership ownership)WidgetOwnership で破棄方法を指定してカスタムの末尾ウィジェットを設定します(自身や祖先ウィジェットは指定できません)。所有権モードを切り替える前に takeTrailingWidget() を呼び出してください。
QWidget* takeTrailingWidget()末尾のウィジェットを削除して返し、呼び出し側で管理または破棄できるようにします。
void releaseTrailingWidget()末尾のウィジェットを削除し、その WidgetOwnership モードに従ってクリーンアップを処理します。
プロパティ
QMargins contentMarginsテキスト周囲のコンテンツ余白(水平方向の値には Qt の内部テキストインセットが含まれます)。
読み取りcontentMargins()書き込みsetContentMargins()通知シグナルcontentMarginsChanged()Typography::FontRole fontRoleテキストに使用される Fluent Typography プリセット。
読み取りfontRole()書き込みsetFontRole()通知シグナルfontRoleChanged()bool clearButtonEnabled末尾のクリアボタンを有効にするかどうか。
読み取りisClearButtonEnabled()書き込みsetClearButtonEnabled()通知シグナルclearButtonEnabledChanged()int clearButtonSizeクリアボタンのサイズ。既定値は 24 論理ピクセルです。
読み取りclearButtonSize()書き込みsetClearButtonSize()通知シグナルclearButtonSizeChanged()QPoint clearButtonOffsetクリアボタンに適用されるピクセルオフセット。
読み取りclearButtonOffset()書き込みsetClearButtonOffset()通知シグナルclearButtonOffsetChanged()int focusedBorderWidthフォーカス時の下枠線の幅。
読み取りfocusedBorderWidth()書き込みsetFocusedBorderWidth()通知シグナルfocusedBorderWidthChanged()int unfocusedBorderWidth非フォーカス時の下枠線の幅。既定値は 0(下線なし)です。
読み取りunfocusedBorderWidth()書き込みsetUnfocusedBorderWidth()通知シグナルunfocusedBorderWidthChanged()bool frameVisibleLineEdit が入力枠とフォーカス下線を描画するかどうかです。
読み取りisFrameVisible()書き込みsetFrameVisible()通知シグナルframeVisibleChanged()QString trailingText- 読み取り
trailingText()書き込みsetTrailingText()通知シグナルtrailingTextChanged() QWidget* trailingWidget- 読み取り
trailingWidget()通知シグナルtrailingWidgetChanged() fluent::WidgetOwnership trailingWidgetOwnership- 読み取り
trailingWidgetOwnership()通知シグナルtrailingWidgetOwnershipChanged() QString clearButtonAccessibleName- 読み取り
clearButtonAccessibleName()書き込みsetClearButtonAccessibleName()通知シグナルclearButtonAccessibleNameChanged() Qt::FocusPolicy clearButtonFocusPolicy- 読み取り
clearButtonFocusPolicy()書き込みsetClearButtonFocusPolicy()通知シグナルclearButtonFocusPolicyChanged()
シグナル
void contentMarginsChanged()テキスト周囲のコンテンツ余白(水平方向の値には Qt の内部テキストインセットが含まれます)。
void fontRoleChanged()テキストに使用される Fluent Typography プリセット。
void clearButtonEnabledChanged()末尾のクリアボタンを有効にするかどうか。
void clearButtonSizeChanged()クリアボタンのサイズ。既定値は 24 論理ピクセルです。
void clearButtonOffsetChanged()クリアボタンに適用されるピクセルオフセット。
void focusedBorderWidthChanged()フォーカス時の下枠線の幅。
void unfocusedBorderWidthChanged()非フォーカス時の下枠線の幅。既定値は 0(下線なし)です。
void frameVisibleChanged()LineEdit が入力枠とフォーカス下線を描画するかどうかです。
protected メンバー
メソッド
virtual void paintFrame(QPainter& painter)frameVisible が有効な場合に入力欄の背景と境界線を描画します。
void paintInputFrame(QPainter& painter, const QRectF& bounds, bool focused, bool hovered, bool pressed = false, bool invalid = false)このコントロールの境界線幅とテーマトークンを使用してカスタム入力フレームを描画します。
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 基底クラスドキュメント:QLineEdit