Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QMediaPlayer Fails with linker errors [SOLVED]

    Installation and Deployment
    3
    5
    1009
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      ion_knight last edited by

      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&#40;"big_buck_bunny_480p_surround-fix.avi"&#41;;
      if(!file.open(QIODevice::ReadOnly&#41;)
          qDebug() << "Could not open file";
      player->setMedia(QUrl::fromLocalFile&#40;"big_buck_bunny_480p_surround-fix.avi"&#41;&#41;;
      player->play();
      widget->show();
      qDebug() << player->availableMetaData() << player->currentMedia().canonicalUrl();
      return app.exec&#40;&#41;;
      

      }
      @

      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 = app

      SOURCES += main.cpp
      mainwindow.cpp

      HEADERS += 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

      1 Reply Last reply Reply Quote 0
      • A
        andreyc last edited by

        Could you put some of the error messages here.

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi,

          You are missing

          @QT += multimediawidgets@

          In you pro file

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • I
            ion_knight last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • A
              andreyc last edited by

              "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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post