i have QT application that plays mp3.
when i call play() function, it plays the music until the mp3 ends. But, i want to play it for 2 seconds.
player->play();
//after 2 seconds
player->stop();
how can i control the time between play and stop?
使用QTimer::singleShot。如果您的播放器有一个名为的插槽,请stop()
使用如下所示的单发计时器:
player->start();
QTimer::singleShot(2000, player, SLOT(stop()));