Home · All Classes · Main Classes · Deprecated |
MButton implementation of a common button widget. More...
Inherits MWidgetController.
Inherited by MHelpButton, and SimpleColoredButton.
Public Slots | |
void | click () |
void | toggle () |
void | setIconVisible (bool) |
void | setTextVisible (bool) |
Signals | |
void | pressed () |
void | released () |
void | clicked (bool checked=false) |
void | toggled (bool checked) |
Public Member Functions | |
MButton (QGraphicsItem *parent=0, MButtonModel *model=0) | |
MButton (const QString &text, QGraphicsItem *parent=0, MButtonModel *model=0) | |
MButton (const QString &iconID, const QString &text, QGraphicsItem *parent=0, MButtonModel *model=0) | |
virtual | ~MButton () |
void | setIconID (const QString &iconID) |
QString | iconID () const |
void | setToggledIconID (const QString &toggledIconID) |
QString | toggledIconID () const |
void | setIcon (const QIcon &icon) |
QIcon | icon () const |
QString | text () const |
void | setText (const QString &text) |
bool | isTextVisible () const |
bool | isIconVisible () const |
bool | isCheckable () const |
void | setCheckable (bool) |
void | setDown (bool) |
bool | isDown () const |
bool | isChecked () const |
void | setChecked (bool) |
MButtonGroup * | group () const |
Static Public Attributes | |
static const MTheme::ViewType | toggleType = "toggle" |
static const MTheme::ViewType | checkboxType = "checkbox" |
static const MTheme::ViewType | iconType = "icon" |
static const MTheme::ViewType | switchType = "switch" |
static const MTheme::ViewType | groupType = "group" |
Protected Slots | |
void | modelClick () |
Properties | |
QString | text |
QString | iconID |
QString | toggledIconID |
QIcon | icon |
bool | textVisible |
bool | iconVisible |
bool | checkable |
bool | checked |
bool | down |
MButton implementation of a common button widget.
MButton provides functionality of check, toggle and push button types. A button can display a label containing text and an icon. setText() sets the text. setIconID() sets the logical icon identifier.
MButton provides the following states for buttons:
The difference between isDown() and isChecked() is as follows. When the user clicks a toggle button to check it, the button is first pressed then released into the checked state. When the user clicks it again (to uncheck it), the button moves first to the pressed state, then to the unchecked state (isChecked() and isDown() are both false).
MButton provides the following signals:
Constructing different button variants:
//push button with text MButton* pushButton = new MButton("Push Button"); //checkbox MButton* checkbox = new MButton(); checkbox->setViewType(MButton::checkboxType); checkbox->setCheckable(true); //toggle button MButton* toggleButton = new MButton("Toggle Button"); toggleButton->setViewType(MButton::toggleType); toggleButton->setCheckable(true); //switch MButton* switch = new MButton(); switch->setViewType(MButton::switchType); switch->setCheckable(true); //icon button MButton* iconButton = new MButton(); iconButton->setViewType(MButton::iconType);
Connecting to user input signals:
//receive user input event from push button MButton* pushButton = new MButton("Push Button"); connect(pushButton, SIGNAL(clicked()), this, SLOT(buttonClicked())); connect(pushButton, SIGNAL(pressed()), this, SLOT(buttonPressed())); connect(pushButton, SIGNAL(released()), this, SLOT(buttonReleased())); //receive user input event from checkable buttons //(checkbox, togglebutton and switch) MButton* checkable = new MButton(); checkable->setViewType(MButton::checkboxType); checkable->setCheckable(true); connect(checkable, SIGNAL(clicked(bool)), this, SLOT(checkableClicked(bool))); connect(checkable, SIGNAL(toggled(bool)), this, SLOT(checkableToggled(bool)));
Connecting to user input signals:
MButton::MButton | ( | QGraphicsItem * | parent = 0 , |
|
MButtonModel * | model = 0 | |||
) | [explicit] |
Constructs a button without text.
MButton::MButton | ( | const QString & | text, | |
QGraphicsItem * | parent = 0 , |
|||
MButtonModel * | model = 0 | |||
) | [explicit] |
Constructs a button with text.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MButton::MButton | ( | const QString & | iconID, | |
const QString & | text, | |||
QGraphicsItem * | parent = 0 , |
|||
MButtonModel * | model = 0 | |||
) |
Constructs a button with icon and text.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MButton::~MButton | ( | ) | [virtual] |
Destroys the button.
void MButton::click | ( | ) | [slot] |
Performs a click.
All the usual signals associated with a click are emitted as appropriate. If the button is checkable, the state of the button is toggled.
void MButton::clicked | ( | bool | checked = false |
) | [signal] |
This signal is emitted when the button is activated.
Notably, this signal is not emitted if you call setDown(), setChecked() or toggle().
If the button is checkable, checked is true if the button is checked, or false if the button is unchecked.
MButtonGroup * MButton::group | ( | ) | const |
Returns the group that this button belongs to.
If the button is not a member of any MButtonGroup, this function returns 0.
QString MButton::iconID | ( | ) | const |
Returns the logical ID of the icon of the button.
bool MButton::isCheckable | ( | ) | const |
Returns true if the button is checkable.
bool MButton::isChecked | ( | ) | const |
Returns true if the button is checked.
bool MButton::isDown | ( | ) | const |
Returns true if the button is pressed down.
bool MButton::isIconVisible | ( | ) | const |
Returns true if the icon of the button is visible.
bool MButton::isTextVisible | ( | ) | const |
Returns true if the text of the button is visible.
void MButton::modelClick | ( | ) | [protected, slot] |
void MButton::pressed | ( | ) | [signal] |
This signal is emitted when the button is pressed down.
void MButton::released | ( | ) | [signal] |
This signal is emitted when the button is released.
void MButton::setCheckable | ( | bool | buttonCheckable | ) |
Set the button to be checkable.
By default, the button is not checkable.
void MButton::setChecked | ( | bool | buttonChecked | ) |
Sets the checked state of the button.
Only checkable buttons can be checked. By default, the button is unchecked.
void MButton::setDown | ( | bool | status | ) |
Set the button down state programmatically.
Unless you are implementing your own button type, you should not need to call this.
void MButton::setIcon | ( | const QIcon & | icon | ) |
Sets the icon of the button.
void MButton::setIconID | ( | const QString & | iconID | ) |
Sets the logical ID of the icon of the button.
void MButton::setIconVisible | ( | bool | iconVisible | ) | [slot] |
Set the visibility of the icon of the button.
void MButton::setText | ( | const QString & | text | ) |
Set the text of the button.
void MButton::setTextVisible | ( | bool | textVisible | ) | [slot] |
Set the visibility of the text of the button.
void MButton::setToggledIconID | ( | const QString & | toggledIconID | ) |
Sets the logical ID of the toggled icon of the button.
QString MButton::text | ( | ) | const |
Returns the text of the button.
If the button has no text, the text() function will return an empty string.
There is no default text.
void MButton::toggle | ( | ) | [slot] |
Toggles the state of a checkable button.
void MButton::toggled | ( | bool | checked | ) | [signal] |
This signal is emitted whenever a checkable button changes its state.
checked is true if the button is checked, or false if the button is unchecked.
This may be the result of a user action, click() slot activation, or because setChecked() was called.
QString MButton::toggledIconID | ( | ) | const |
Returns the logical ID of the toggled icon of the button.
const MTheme::ViewType MButton::checkboxType = "checkbox" [static] |
Variable that defines id for checkbox button variant.
const MTheme::ViewType MButton::groupType = "group" [static] |
Variable that defines id for a buttons inside button groups.
const MTheme::ViewType MButton::iconType = "icon" [static] |
Variable that defines id for icon button variant.
const MTheme::ViewType MButton::switchType = "switch" [static] |
Variable that defines id for switch button variant.
const MTheme::ViewType MButton::toggleType = "toggle" [static] |
Variable that defines id for toggle button variant.
MButton::checkable [read, write] |
MButton::checked [read, write] |
MButton::down [read, write] |
See MButtonModel::down.
MButton::icon [read, write] |
See MButtonModel::icon.
MButton::iconID [read, write] |
See MButtonModel::iconID.
MButton::iconVisible [read, write] |
MButton::text [read, write] |
See MButtonModel::text.
MButton::textVisible [read, write] |
MButton::toggledIconID [read, write] |
Copyright © 2010 Nokia Corporation | MeeGo Touch |