QMediaPlayer编译错误

QMediaPlayer编译错误

本文介绍了QMediaPlayer编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装Qt5,因为Phonon不支持在Qt5我被迫使用别的东西,所以我决定使用QtMultimedia。



.pro文件: / p>

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

.cpp代码:

  #includemainwindow.h
#includeui_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();
}

但我遇到以下错误:



>



解决方案

在.pro文件中将多媒体模块添加到QT中,运行qmake 并建立您的专案:

  QT + = core gui multimedia 

在Qt 5中,QMediaPlayer类位于多媒体。
您可能需要模块(我看到你有一个主窗口)



LE:使用包含无模块文件夹:

  #include< QMediaPlayer> 


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:

How can I solve this. Thank you

解决方案

Add multimedia module to QT in .pro file, run qmake and than 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>

这篇关于QMediaPlayer编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 06:14