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

  • Qt 4.8
  • Qt3SupportLight
  • Q3ButtonGroup

Q3ButtonGroup Class

TheQ3ButtonGroup widget organizesQAbstractButton widgets in a group.More...

Header:#include <Q3ButtonGroup>
Inherits:Q3GroupBox
Inherited By:

Q3HButtonGroup andQ3VButtonGroup

Properties

Public Functions

Q3ButtonGroup(QWidget * parent = 0, const char * name = 0)
Q3ButtonGroup(const QString & title, QWidget * parent = 0, const char * name = 0)
Q3ButtonGroup(int strips, Qt::Orientation orientation, QWidget * parent = 0, const char * name = 0)
Q3ButtonGroup(int strips, Qt::Orientation orientation, const QString & title, QWidget * parent = 0, const char * name = 0)
~Q3ButtonGroup()
intcount() const
QAbstractButton *find(int id) const
intid(QAbstractButton * button) const
intinsert(QAbstractButton * button, int id = -1)
boolisExclusive() const
boolisRadioButtonExclusive() const
voidremove(QAbstractButton * button)
QAbstractButton *selected() const
intselectedId() const
voidsetButton(int id)
voidsetExclusive(bool)
voidsetRadioButtonExclusive(bool)

Signals

voidclicked(int id)
voidpressed(int id)
voidreleased(int id)

Reimplemented Protected Functions

virtual boolevent(QEvent * e)
  • 4 protected functions inherited fromQ3GroupBox
  • 10 protected functions inherited fromQGroupBox
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 1 public slot inherited fromQGroupBox
  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject
  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 4 protected functions inherited fromQ3GroupBox
  • 10 protected functions inherited fromQGroupBox
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice
  • 1 protected slot inherited fromQWidget

Detailed Description

TheQ3ButtonGroup widget organizesQAbstractButton widgets in a group.

A button group widget makes it easier to deal with groups of buttons. Each button in a button group has a unique identifier. The button group emits aclicked() signal with this identifier when a button in the group is clicked. This makes a button group particularly useful when you have several similar buttons and want to connect all theirclicked() signals to a single slot.

Anexclusive button group switches off all toggle buttons except the one that was clicked. A button group is, by default, non-exclusive. Note that all radio buttons that are inserted into a button group are mutually exclusive even if the button group is non-exclusive. (SeesetRadioButtonExclusive().)

There are two ways of using a button group:

  • The button group is the parent widget of a number of buttons, i.e. the button group is the parent argument in the button constructor. The buttons are assigned identifiers 0, 1, 2, etc., in the order they are created. AQ3ButtonGroup can display a frame and a title because it inheritsQ3GroupBox.
  • The button group is an invisible widget and the contained buttons have some other parent widget. In this usage, each button must be manually inserted, usinginsert(), into the button group and given an identifier.

A button can be removed from the group withremove(). A pointer to a button with a given id can be obtained usingfind(). The id of a button is available usingid(). A button can be seton withsetButton(). The number of buttons in the group is returned bycount().

See alsoQPushButton,QCheckBox, andQRadioButton.

Property Documentation

exclusive :bool

This property holds whether the button group is exclusive.

If this property is true, then the buttons in the group are toggled, and to untoggle a button you must click on another button in the group. The default value is false.

Access functions:

boolisExclusive() const
voidsetExclusive(bool)

radioButtonExclusive :bool

This property holds whether the radio buttons in the group are exclusive.

If this property is true (the default), theradio buttons in the group are treated exclusively.

Access functions:

boolisRadioButtonExclusive() const
voidsetRadioButtonExclusive(bool)

selectedId :int

This property holds the id of the selected toggle button.

If no toggle button is selected,id() returns -1.

If setButton() is called on an exclusive group, the button with the given id will be set to on and all the others will be set to off.

Access functions:

intselectedId() const
voidsetButton(int id)

See alsoselected().

Member Function Documentation

Q3ButtonGroup::Q3ButtonGroup(QWidget * parent = 0, constchar * name = 0)

Constructs a button group with no title.

Theparent andname arguments are passed to theQWidget constructor.

Q3ButtonGroup::Q3ButtonGroup(constQString & title,QWidget * parent = 0, constchar * name = 0)

Constructs a button group with the titletitle.

Theparent andname arguments are passed to theQWidget constructor.

Q3ButtonGroup::Q3ButtonGroup(int strips,Qt::Orientation orientation,QWidget * parent = 0, constchar * name = 0)

Constructs a button group with no title. Child widgets will be arranged instrips rows or columns (depending onorientation).

Theparent andname arguments are passed to theQWidget constructor.

Q3ButtonGroup::Q3ButtonGroup(int strips,Qt::Orientation orientation, constQString & title,QWidget * parent = 0, constchar * name = 0)

Constructs a button group with titletitle. Child widgets will be arranged instrips rows or columns (depending onorientation).

Theparent andname arguments are passed to theQWidget constructor.

Q3ButtonGroup::~Q3ButtonGroup()

Destructor.

[signal]void Q3ButtonGroup::clicked(int id)

This signal is emitted when a button in the group isclicked. Theid argument is the button's identifier.

See alsoinsert().

int Q3ButtonGroup::count() const

Returns the number of buttons in the group.

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

Reimplemented fromQObject::event().

QAbstractButton * Q3ButtonGroup::find(int id) const

Returns the button with the specified identifierid, or 0 if the button was not found.

int Q3ButtonGroup::id(QAbstractButton * button) const

Returns the id ofbutton, or -1 ifbutton is not a member of this group.

See alsoselectedId().

int Q3ButtonGroup::insert(QAbstractButton * button,int id = -1)

Inserts thebutton with the identifierid into the button group. Returns the button identifier.

Buttons are normally inserted into a button group automatically by passing the button group as the parent when the button is constructed. So it is not necessary to manually insert buttons that have this button group as their parent widget. An exception is when you want custom identifiers instead of the default 0, 1, 2, etc., or if you want the buttons to have some other parent.

The button is assigned the identifierid or an automatically generated identifier. It works as follows: Ifid >= 0, this identifier is assigned. Ifid == -1 (default), the identifier is equal to the number of buttons in the group. Ifid is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated. No button has an id of -1.

See alsofind(),remove(), andsetExclusive().

[signal]void Q3ButtonGroup::pressed(int id)

This signal is emitted when a button in the group ispressed. Theid argument is the button's identifier.

See alsoinsert().

[signal]void Q3ButtonGroup::released(int id)

This signal is emitted when a button in the group isreleased. Theid argument is the button's identifier.

See alsoinsert().

void Q3ButtonGroup::remove(QAbstractButton * button)

Removes thebutton from the button group.

See alsoinsert().

QAbstractButton * Q3ButtonGroup::selected() const

Returns the selected toggle button if exactly one is selected; otherwise returns 0.

See alsoselectedId().

© 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