Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 刚刚接触QT,菜单直接打开链接都某个文件
Forum Updated to NodeBB v4.3 + New Features

刚刚接触QT,菜单直接打开链接都某个文件

Scheduled Pinned Locked Moved Unsolved Chinese
3 Posts 2 Posters 501 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.
  • X Offline
    X Offline
    xiayizhan
    wrote on last edited by
    #1
    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);
    
    1 Reply Last reply
    0
    • X Offline
      X Offline
      xiayizhan
      wrote on last edited by
      #2

      刚刚接触QT,菜单直接打开链接到某个文件"

      1 Reply Last reply
      0
      • Grit ClefG Offline
        Grit ClefG Offline
        Grit Clef
        wrote on last edited by Grit Clef
        #3

        您试试在相应的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();
        
        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