How to programmatically click a QPushButton

c++, qt

Solution

Use `QAbstractButton::animateClick()`:

QPushButton* startButton = new QPushButton("Start");
startButton->animateClick();

Problem

I am using Qt. I have a button in the page added via the Qt Creator. It is connected to the method `void MyPage::on_startButton_clicked()`. I want to programmatically click this button. I tried `ui->startButton->clicked()`, it gives, error C2248: 'QAbstractButton::clicked' : cannot access protected member declared in class 'QAbstractButton' Please help. Thanks!

Original source