【问题标题】:QT, running the function for specific timeQT,运行特定时间的功能
【发布时间】:2013-04-28 13:15:52
【问题描述】:

我有播放 mp3 的 QT 应用程序。

当我调用 play() 函数时,它会播放音乐直到 mp3 结束。但是,我想玩 2 秒。

player->play();
//after 2 seconds
player->stop();

如何控制播放和停止之间的时间?

【问题讨论】:

    标签: c++ qt timer


    【解决方案1】:

    使用QTimer::singleShot。如果您的播放器有一个名为 stop() 的插槽,请使用这样的单发计时器:

    player->start();
    QTimer::singleShot(2000, player, SLOT(stop()));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-22
      • 2016-08-01
      • 2020-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-05
      • 1970-01-01
      相关资源
      最近更新 更多