Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QMediaPlayer undefined-reference linker errors

Tags:

c++

qt

I installed Qt5 and since Phonon is not supported in Qt5 I'm forced to use something else, so I decided to use QtMultimedia.

.pro file:

QT       += core gui
CONFIG += mobility
MOBILITY += multimedia

.cpp code:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtGui>
#include <QtCore>
#include <QtMultimedia/QMediaPlayer>

...

void MainWindow::on_pushButton_clicked()
{
    QMediaPlayer *player = new QMediaPlayer(this);
    player->setVolume(50);
    player->setMedia(QUrl::fromLocalFile("some_path"));
    player->play();
}

But I'm getting following errors:

enter image description here

How can I solve this. Thank you

like image 789
Alen Avatar asked Feb 20 '13 13:02

Alen


1 Answers

Add multimedia module to QT in .pro file, run qmake and then build your project:

QT += core gui multimedia

In Qt 5 that QMediaPlayer class is in multimedia module. And you might want the widgets module too (i see you have a mainwindow)

LE: Use the include without module folder:

#include <QMediaPlayer> 
like image 57
Zlatomir Avatar answered Oct 05 '22 03:10

Zlatomir