Qt 從選單欄開啟檔案

2022-07-01 12:21:07 字數 638 閱讀 2288

qt從選單欄的下拉列表選擇檔案

建構函式中設定開啟動作資訊

//開啟檔案

m_menu = ui.menu;

// m_menu->menuaction = new qaction(qicon(tr("images/open.ico")), tr("開啟檔案"), this);

qaction *action = new qaction(tr("開啟檔案"), this);

//設定開啟檔案按鈕的快捷方式

action->setshortcut(tr("ctrl+o"));

m_menu->addaction(action);

//關聯訊號和槽

qobject::connect(action, signal(triggered()), this, slot(openfile()));

開啟檔案的實現函式

void player_qt::openfile()

//qstring轉string

std::string strpath = str_path.tostdstring();

}

更多參考

Qt 從選單欄開啟檔案

qt從選單欄的下拉列表選擇檔案 建構函式中設定開啟動作資訊 開啟檔案 m menu ui.menu m menu menuaction new qaction qicon tr images open.ico tr 開啟檔案 this qaction action new qaction tr 開啟...

qt選單欄開發知識

複習一下qt選單欄設定 cpdropdownwidget cpdropdownwidget qwidget parent qpushbutton parent 繼承按鈕 setobjectname header dropdown setfixedsize qsize 30,30 新增下拉視窗,裡面包...

Qt學習 實戰 選單欄

qt中用 實現乙個選單欄 include mainwindow.h include include 新增選單欄 include 新增選單 include 新增動作 include 新增工具欄 include 新增狀態列 include 新增標籤 include 核心控制項 include 浮動視窗 ...