1
나는 Qt에서 초보자입니다. QMediaPlayer
에 문제가 있습니다 : 내 프로그램에는 2 가지 양식 (기본 양식 및 통지)이 있습니다. 따라서 조건이 있고 사실이라면 프로그램은 두 번째 형식을 표시하고로드 형식으로 음악을 재생해야합니다. 그것이 작동 할두 번째 형식의 QMediaPlayer 사용
uix->label->setText("qwerty");
: 같은
MAIN.CPP
#include "mainwindow.h"
#include <QApplication>
#include "dialog.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
Dialog d;
d.musicPlay();
d.show();
return a.exec();
}
dialog.cpp
#include "dialog.h"
#include "ui_dialog.h"
#include <QMediaPlayer>
#include <QUrl>
#include <QDebug>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
uix(new Ui::Dialog)
{
uix->setupUi(this);
}
void Dialog::musicPlay() const
{
QMediaPlayer pl;
pl.setMedia(QUrl::fromLocalFile("/home/jack/01.mp3"));
pl.setVolume(100);
pl.play();
qDebug()<<pl.errorString();
}
Dialog::~Dialog()
{
delete uix;
}
그것은 작동하지 않지만, musicPlay 경우()가 될 것이다. 이 문제를 해결하는 데 도움을 줄 수 있습니까? 슬롯과 신호를 사용해야합니까?
고마워요! 나는 pointer.h를 dialog.h에 선언하고 작동한다) –