Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QMediaPlayer Fails with linker errors [SOLVED]

QMediaPlayer Fails with linker errors [SOLVED]

Scheduled Pinned Locked Moved Installation and Deployment
5 Posts 3 Posters 1.3k Views
  • 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 Offline
    I Offline
    ion_knight
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Could you put some of the error messages here.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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
        0
        • I Offline
          I Offline
          ion_knight
          wrote on last edited by
          #4

          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
          0
          • A Offline
            A Offline
            andreyc
            wrote on last edited by
            #5

            "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
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved