Wt 3.1.10
|
A widget that represents a push button. More...
#include <Wt/WPushButton>
Public Member Functions | |
WPushButton (WContainerWidget *parent=0) | |
Creates a push button. | |
WPushButton (const WString &text, WContainerWidget *parent=0) | |
Creates a push button with given label text. | |
void | setText (const WString &text) |
Sets the button text. | |
const WString & | text () const |
Returns the button text. | |
void | setIcon (const std::string &url) |
Sets an icon. | |
const std::string & | icon () const |
Returns the icon. | |
void | setRef (const std::string &url) |
Sets a destination URL. | |
const std::string & | ref () const |
Returns the destination URL. | |
void | setResource (WResource *resource) |
Sets a destination resource. | |
WResource * | resource () const |
Returns the destination resource. | |
virtual void | refresh () |
Refresh the widget. |
A widget that represents a push button.
To act on a button click, connect a slot to the clicked() signal.
Usage example:
Wt::WPushButton *ok = new Wt::WPushButton("Okay"); ok->clicked().connect(ok, &Wt::WPushButton::disable); ok->clicked().connect(this, &MyClass::processData);
WPushButton is an inline widget.
The widget corresponds to the HTML <button>
tag and has the Wt-btn
style. It may be styled through the current theme, or you can override the style using internal or external CSS as appropriate.
const std::string& Wt::WPushButton::icon | ( | ) | const |
Returns the icon.
const std::string& Wt::WPushButton::ref | ( | ) | const |
Returns the destination URL.
When the button refers to a resource, the current resource URL is returned. Otherwise, the URL is returned that was set using setRef().
void Wt::WPushButton::refresh | ( | ) | [virtual] |
Refresh the widget.
The refresh method is invoked when the locale is changed using WApplication::setLocale() or when the user hit the refresh button.
The widget must actualize its contents in response.
Reimplemented from Wt::WFormWidget.
WResource* Wt::WPushButton::resource | ( | ) | const |
void Wt::WPushButton::setIcon | ( | const std::string & | url | ) |
Sets an icon.
The icon is placed to the left of the text.
void Wt::WPushButton::setRef | ( | const std::string & | url | ) |
Sets a destination URL.
This method can be used to make the button behave like a WAnchor (or conversely, an anchor look like a button) and redirect to another URL when clicked.
By default, a button does not refer to an URL and you should listen to the clicked() signal to react to a click event.
void Wt::WPushButton::setResource | ( | WResource * | resource | ) |
Sets a destination resource.
This method can be used to make the button behave like a WAnchor (or conversely, an anchor look like a button) and redirect to another resource when clicked.
A resource specifies application-dependent content, which may be generated by your application on demand.
This sets the resource
as the destination of the button, and is an alternative to setRef(). The resource may be cleared by passing resource
= 0
.
The button does not assume ownership of the resource.