C++ (Qt)#-------------------------------------------------## Project created by QtCreator 2021-02-09T12:21:36##------------------------------------------------- greaterThan(QT_MAJOR_VERSION, 4): QT += widgets QT += core guiQT += core gui multimedia QMAKE_LFLAGS += -no-pie TARGET = aplr2TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ widget.cpp HEADERS += \ widget.h FORMS += \ widget.ui
C++ (Qt)#ifndef WIDGET_H#define WIDGET_H #include <QWidget>#include <QMediaPlayer>#include <QDir>#include <QUrl> namespace Ui {class Widget;} class Widget : public QWidget{ Q_OBJECT public: explicit Widget(QWidget *parent = 0); ~Widget(); private: Ui::Widget *ui; QMediaPlayer *m_player; public slots: void press_pbtn_01();}; #endif // WIDGET_H
C++ (Qt)#include "widget.h"#include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this); //m_player = new QMediaPlayer(this); QObject::connect(ui->pbtn_01, SIGNAL(clicked()), this, SLOT(press_pbtn_01()));} Widget::~Widget(){ delete ui;} void Widget::press_pbtn_01(){ QString str = QUrl::fromLocalFile(":/home/alexu/music/Here.mp3").toString(); ui->label->setText(str);}