Engine
Engine

Reputation: 5432

How can I check if QPushButton is clicked

I want to use an if-else statement to check if QPushButton is clicked or not.
How can I do this?.

Upvotes: 2

Views: 11320

Answers (2)

cppguy
cppguy

Reputation: 3713

QAbstractButton, QPushButton's parent class, has a checked property (setChecked/isChecked) if you're trying to determine if the button is depressed with the checkable property set to true.

Upvotes: 2

Johan Råde
Johan Råde

Reputation: 21418

The question does not make sense. Being clicked is not a state that you can check; clicking a button is an event. It is important to distinguish between states and events.

You handle a button click event by connecting a slot to the signal QAbstractButton::clicked().

Maybe you mean "How do I check if a button is down?". Being down is a state; you check that state using the method QAbstractButton::isDown().

Upvotes: 10

Related Questions