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 です。auto-exclusive が有効になっている場合、同じ親ウィジェットに属するラジオボタンは、あたかも同じ排他ボタングループの一部であるかのように動作します。同じ親ウィジェットに属するラジオボタンに対して複数の排他ボタングループが必要な場合は、それらを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()。
QPushButton 、QToolButton 、およびQCheckBoxも参照してください 。
メンバ関数のドキュメント
[explicit] QRadioButton::QRadioButton(QWidget *parent = nullptr)
指定されたparent を使用してラジオボタンを生成しますが、テキストやピクマップは設定されません。
parent 引数は、QAbstractButton のコンストラクタに渡されます。
[explicit] QRadioButton::QRadioButton(const QString &text, QWidget *parent = nullptr)
指定されたparent およびtext の文字列を使用して、ラジオボタンを生成します。
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
option を、QRadioButton の値を用いて初期化します。このメソッドは、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 」のアクセス関数を再実装します。
© 2026 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.