Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QRadioButton Class

TheQRadioButton widget provides a radio button with a text label.More...

Header:#include <QRadioButton>
Inherits:QAbstractButton

Public Functions

QRadioButton(QWidget * parent = 0)
QRadioButton(const QString & text, QWidget * parent = 0)

Reimplemented Public Functions

virtual QSizeminimumSizeHint() const
virtual QSizesizeHint() const

Protected Functions

voidinitStyleOption(QStyleOptionButton * option) const

Reimplemented Protected Functions

virtual boolevent(QEvent * e)
virtual boolhitButton(const QPoint & pos) const
virtual voidmouseMoveEvent(QMouseEvent * e)
virtual voidpaintEvent(QPaintEvent *)

Additional Inherited Members

Detailed Description

TheQRadioButton widget provides a radio button with a text label.

AQRadioButton is an option button that can be switched on (checked) or off (unchecked). Radio buttons typically present the user with a "one of many" choice. In a group of radio buttons only one radio button at a time can be checked; if the user selects another button, the previously selected button is switched off.

Radio buttons areautoExclusive by default. If auto-exclusive is enabled, radio buttons that belong to the same parent widget behave as if they were part of the same exclusive button group. If you need multiple exclusive button groups for radio buttons that belong to the same parent widget, put them into aQButtonGroup.

Whenever a button is switched on or off it emits thetoggled() signal. Connect to this signal if you want to trigger an action each time the button changes state. UseisChecked() to see if a particular button is selected.

Just likeQPushButton, a radio button displays text, and optionally a small icon. The icon is set withsetIcon(). The text can be set in the constructor or withsetText(). A shortcut key can be specified by preceding the preferred character with an ampersand in the text. For example:

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

In this example the shortcut isAlt+c. See theQShortcut documentation for details (to display an actual ampersand, use '&&').

Important inherited members:text(),setText(),text(),setDown(),isDown(),autoRepeat(),group(),setAutoRepeat(),toggle(),pressed(),released(),clicked(), andtoggled().

Screenshot of a Plastique radio buttonA radio button shown in thePlastique widget style.
Screenshot of a Windows XP radio buttonA radio button shown in theWindows XP widget style.
Screenshot of a Macintosh radio buttonA radio button shown in theMacintosh widget style.

See alsoQPushButton,QToolButton,QCheckBox,GUI Design Handbook: Radio Button, andGroup Box Example.

Member Function Documentation

QRadioButton::QRadioButton(QWidget * parent = 0)

Constructs a radio button with the givenparent, but with no text or pixmap.

Theparent argument is passed on to theQAbstractButton constructor.

QRadioButton::QRadioButton(constQString & text,QWidget * parent = 0)

Constructs a radio button with the givenparent and atext string.

Theparent argument is passed on to theQAbstractButton constructor.

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

Reimplemented fromQObject::event().

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

Reimplemented fromQAbstractButton::hitButton().

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

Initializeoption with the values from thisQRadioButton. This method is useful for subclasses when they need aQStyleOptionButton, but don't want to fill in all the information themselves.

See alsoQStyleOption::initFrom().

[virtual]QSize QRadioButton::minimumSizeHint() const

Reimplemented fromQWidget::minimumSizeHint().

This function was introduced in Qt 4.8.

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

Reimplemented fromQWidget::mouseMoveEvent().

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

Reimplemented fromQWidget::paintEvent().

[virtual]QSize QRadioButton::sizeHint() const

Reimplemented fromQWidget::sizeHint().

© 2016 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 theGNU 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.


[8]ページ先頭

©2009-2025 Movatter.jp