Multiplier
Multiplier

Reputation: 31

Start-of-Program signal Qt C++

I am currently calling an animation function when I press a push button with on_pushButton_3_clicked(). However, I want it to execute right away when the program starts. Is there a way to do this with the same inbuilt function that reads the name of components in the .ui file?

Here is a sample of my code:

void myClass::on_pushButton_3_clicked()
{
    // Animation Function Code
}

Upvotes: 3

Views: 134

Answers (1)

Adrian Maire
Adrian Maire

Reputation: 14845

A simple way to solve this is to trigger a timer:

#include <QTimer>

...
int main()
{
    ...

    QTimer::singleShot(100, [=](){ emit myClassObj.on_pushButton_3_clicked(); });
    ...
    app.exec();
}

Upvotes: 3

Related Questions