刚刚接触QT,菜单直接打开链接都某个文件
Unsolved
Chinese
-
QAction *savePlaylistAct = new QAction("保存播放列表(&S)", this); connect(savePlaylistAct, &QAction::triggered, this, &Player::savePlaylist); QAction *loadPlaylistAct = new QAction("加载播放列表(&L)", this); connect(loadPlaylistAct, &QAction::triggered, this, &Player::loadPlaylist); QAction *openLocalFileAction = new QAction("打开视频1", this);
这里怎么写,菜单点击打开视频1,就能打开我程序下1.mp4
fileMenu->addAction(openLocalFileAction);
-
您试试在相应的action里头打开文件?
比如QAction *openLocalFileAction = new QAction("打开视频1", this); connect(openLocalFileAction, &QAction::triggered, this, &Player::openLocalFile);
然后在槽中写入类似于
#include <QtMultimedia> #include <QtMultimediaWidgets> ... QMediaPlayer *player = new QMediaPlayer; player->setMedia(QMediaContent(QUrl("1.mp4"))); QVideoWidget *videoWidget = new QVideoWidget; player->setVideoOutput(videoWidget); videoWidget->show(); player->play();