QRadioButton Class

QRadioButtonウィジェットは、テキストラベル付きのラジオボタンを提供します。詳細...

ヘッダー #include <QRadioButton>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
継承: QAbstractButton

パブリック関数

QRadioButton(QWidget *parent = nullptr)
QRadioButton(const QString &text, QWidget *parent = nullptr)
virtual ~QRadioButton()

再実装パブリック関数

virtual QSize minimumSizeHint() const override
virtual QSize sizeHint() const override

保護された関数

virtual void initStyleOption(QStyleOptionButton *option) const

再実装された保護された関数

virtual bool event(QEvent *e) override
virtual bool hitButton(const QPoint &pos) const override
virtual void mouseMoveEvent(QMouseEvent *e) override
virtual void paintEvent(QPaintEvent *) override

詳細説明

QRadioButtonは、オン(チェック)またはオフ(チェックなし)に切り替えられるオプションボタンです。ラジオボタンは通常、ユーザーに「多くの選択肢のうちの1つ」を提示します。ラジオボタンのグループでは、一度に1つのラジオボタンのみをチェックすることができ、ユーザーが別のボタンを選択すると、前に選択されたボタンはオフになります。

ラジオボタンはデフォルトでautoExclusiveです。オートエクスクルーシブが有効な場合、同じ親ウィジェットに属するラジオボタンは、同じエクスクルーシブボタングループに属しているかのように動作します。同じ親ウィジェットに属するラジオボタンに複数の排他的ボタングループが必要な場合は、QButtonGroup

ボタンがオンまたはオフに切り替わるたびに、ボタンはtoggled() シグナルを発信します。ボタンの状態が変わるたびにアクションをトリガーしたい場合は、このシグナルに接続してください。特定のボタンが選択されているかどうかを調べるには、isChecked() を使用します。

QPushButton のように、ラジオ・ボタンはテキストと、オプションで小さなアイコンを表示します。アイコンはsetIcon() で設定します。テキストは、コンストラクタまたはsetText() で設定できます。ショートカット・キーは、テキスト中の優先文字の前にアンパサンドを置くことで指定できます。例えば

QRadioButton *button = new QRadioButton("Search from the &cursor", this);

この例では、ショートカットはAlt+cです。詳細はQShortcut のドキュメントを参照してください。実際のアンパサンドを表示するには、'&&' を使用する。

重要な継承メンバ:text()、setText()、text()、setDown()、isDown()、autoRepeat()、group()、setAutoRepeat()、toggle()、pressed()、released()、clicked()、toggled()。

QPushButtonQToolButtonQCheckBoxも参照のこと

メンバー関数ドキュメント

[explicit] QRadioButton::QRadioButton(QWidget *parent = nullptr)

与えられたparent で、テキストも pixmap もないラジオボタンを構築します。

parent 引数はQAbstractButton コンストラクタに渡されます。

[explicit] QRadioButton::QRadioButton(const QString &text, QWidget *parent = nullptr)

与えられたparenttext 文字列でラジオボタンを構築する。

parent 引数はQAbstractButton コンストラクタに渡されます。

[virtual noexcept] QRadioButton::~QRadioButton()

破壊者。

[override virtual protected] bool QRadioButton::event(QEvent *e)

再インプリメント:QAbstractButton::event(QEvent *e).

[override virtual protected] bool QRadioButton::hitButton(const QPoint &pos) const

再実装:QAbstractButton::hitButton(const QPoint &pos) const.

[virtual protected] void QRadioButton::initStyleOption(QStyleOptionButton *option) const

QRadioButton の値でoption を初期化する。このメソッドは、サブクラスがQStyleOptionButton を必要とするが、すべての情報を自分で入力したくない場合に便利です。

QStyleOption::initFrom()も参照

[override virtual] QSize QRadioButton::minimumSizeHint() const

QWidget::minimumSizeHint

[override virtual protected] void QRadioButton::mouseMoveEvent(QMouseEvent *e)

再実装:QAbstractButton::mouseMoveEvent(QMouseEvent *e).

[override virtual protected] void QRadioButton::paintEvent(QPaintEvent *)

再実装:QAbstractButton::paintEvent(QPaintEvent *e).

[override virtual] QSize QRadioButton::sizeHint() const

QWidget::sizeHint

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.