gpt4 book ai didi

c++ - QSound播放.wav文件时出现意外的null接收器

转载 作者:行者123 更新时间:2023-12-03 01:56:53 27 4
gpt4 key购买 nike

我想通过Qt Creator播放引擎的.wav示例。当然,第一个想法是关于QSound的,但是我做了一切必要的演奏,它总是向我展示

QCoreApplication::postEvent: Unexpected null receiver

这意味着我输入了错误的文件路径,这似乎很简单,但是我尝试了绝对路径等。

源代码和照片,我正在Windows上尝试,但我想在Raspberry(fedora)上运行它。
#include <QCoreApplication>
#include <QSound>
#include <iostream>
#include <QMediaPlayer>



int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSound let("music/letitplay.wav");
let.play();


/*QMediaPlayer * music = new QMediaPlayer();
music->setMedia(QUrl("qrc:/sounds/letitplay.wav"));
music->play();
*/

return 0;
}

.pro的片段
QT += core
QT -= gui
QT += multimedia

TARGET = silnik1
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

RESOURCES +=

Screen of path and file directory

最佳答案

QSound异步播放声音;您将需要先启动QCoreApplication,以便运行一个事件循环。

关于c++ - QSound播放.wav文件时出现意外的null接收器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34623763/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com