rwx
rwx

Reputation: 595

QMediaPlayer, QSound class - unable to #Include files (files are there)

I have been trying to play a simple audio file using:

http://qt-project.org/doc/qt-5/qmediaplayer.html and http://qt-project.org/doc/qt-5/QSound.html

I am using Qt 5.3 but the problem is, when I type #include QMediaPlayer or QSound, QtCreator keeps underlining them with red because it can't find them. The thing is, the files are there. They are located in QtMultimedia/ and I have seen them. When I try to prefix QtMultimedia/QMediaPlayer or QtMultimedia/qmediaplayer.h it still can't find them.

If I type #include "QtMultimedia/" the auto-complete drop down in the text editor only shows QtMultimedia/QtMultimediaDepends. Normally you get a list of all the files in the folder but not with this one.

Looks like there is something wrong with the paths. How do I fix them? I am using a Windows machine.

enter image description hereenter image description here

Edit: I have included project settings - see screenshots.

Upvotes: 2

Views: 3275

Answers (3)

Miguel Tomás
Miguel Tomás

Reputation: 1911

You have to add the word 'multimedia' in your .pro file:

QT += core GUI

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia

Upvotes: 2

zero
zero

Reputation: 193

I think, after you modified your .pro file, You didn't run the qmake.

build-> run qmake

qmake will generate the makefile you need to build the src code. if you only change the .pro file, but didn't run it. Nothing is changed. and that is reason, you create a new project and it is working.

Upvotes: 1

rwx
rwx

Reputation: 595

Ok I figured it out. It's a problem with my Qt version.

My Qt 5.3 version is a custom compiled one. When I select the included version that came with the installer, QSound is found. When I change the kit to the custom compiled one, the file cannot be found. I must have forgotten to include some sort of multimedia option to the configure script during compilation.

Now the question is what is the missing option, I will need to do more reading...

Of course, comments and suggestions are welcome :)

Upvotes: 0

Related Questions