0

I would like to play .wav samples of engine through out Qt creator. Of course the very first thought was on QSound class, but I did whatever was necessary to play it and it always shows me

QCoreApplication::postEvent: Unexpected null receiver

Which means that I entered wrong path for file, it seems simple but I have tried with absoulte paths and etc. Nothing new has happened.

Sourcecode and photos, I am trying it on windows but I would like to run it on 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;
}

Snippet from .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

1 Answers1

0

QSound plays sounds asynchronously; you're going to need to start your QCoreApplication first so there's an event loop running.

MrEricSir
  • 8,044
  • 4
  • 30
  • 35
  • Thank you very much sir, now it shos QSoundEffect(qaudio): Error decoding source but it is a problem with path but I know what to do do. You are the best man all my fault was about return 0, not return a.exec(). –  Jan 06 '16 at 01:25
  • Sounds like a separate question. – MrEricSir Jan 06 '16 at 01:35