QMediaPlayer Fails with linker errors [SOLVED]
-
Below is my code for a very basic player however I am getting a ton of linker errors. Which i have no idea how to solve.
main.cpp
@
#include <QDebug>
#include <QApplication>
#include <QMediaPlayer>
//#include <QVideoWidget>
#include <QtMultimediaWidgets/QVideoWidget>
#include <QVBoxLayout>
#include <QFile>int main(int argc, char** argv)
{
QApplication app(argc, argv);QWidget *widget = new QWidget; widget->resize(400, 300); QVBoxLayout *layout = new QVBoxLayout; QMediaPlayer* player = new QMediaPlayer; QVideoWidget* vw = new QVideoWidget; layout->addWidget(vw); widget->setLayout(layout); player->setVideoOutput(vw); QFile file("big_buck_bunny_480p_surround-fix.avi"); if(!file.open(QIODevice::ReadOnly)) qDebug() << "Could not open file"; player->setMedia(QUrl::fromLocalFile("big_buck_bunny_480p_surround-fix.avi")); player->play(); widget->show(); qDebug() << player->availableMetaData() << player->currentMedia().canonicalUrl(); return app.exec();
}
@RTSP.pro
@#-------------------------------------------------Project created by QtCreator 2014-07-22T14:42:07
#-------------------------------------------------
QT += core gui multimedia
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = RTSP
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui@
Any help on how to proceed from here would be great as pretty lost where to go from here.
Thanks -
Ah ok weird that fixed it, don't suppose you can explain why this worked cause I presumed by using:
#include <QtMultimediaWidgets/QVideoWidget>
I thought i didn't have to include it inside the pro file. Don't suppose you have any good links to explain the .pro file, cause I thought it was just another method of include.
-
"Here":http://qt-project.org/doc/qt-5/qmake-manual.html is some info about .pro and its "variables":http://qt-project.org/doc/qt-5/qmake-variable-reference.html
There is a qmake line in a C++ class doc that specifies what Qt module to add to "QT":http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt variable to use the class. For example in "QVideoWidget Class":http://qt-project.org/doc/qt-5/qvideowidget.html