Simply add the eventhandler to the button when creating it. button. Click += new EventHandler(this. button_Click); void button_Click(object sender, System.
Onclick in XML layout When the user clicks a button, the Button object receives an on-click event. To make click event work add android:onClick attribute to the Button element in your XML layout. The value for this attribute must be the name of the method you want to call in response to a click event.
At first, all buttons are hidden. In page load, I read data from database to show the text of function button; if the function button is not active then the button is also invisible. In that code, I save all active functions in a list and then get the list count.
In the designer,
The terms are different from .NET, so in this case we are talking about signals and slots, and the signal emitted when QPushButton is clicked is called clicked()
instead of OnClick
.
Reading the Qt's documentation about signals and slots is recommended.
private slots:
void exit_app();
connect(ui.button_name, SIGNAL(clicked()), this, SLOT(exit_app()));
void QtTest2::exit_app()
{
QApplication::exit();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With