添加菜单的快捷键
This commit is contained in:
parent
c45f1852c6
commit
0a941954e0
|
@ -17,6 +17,15 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::onOpenButtonClicked);
|
||||
connect(ui->actionSave, &QAction::triggered, this, &MainWindow::onSaveButtonClicked);
|
||||
|
||||
QIcon openIcon = QApplication::style()->standardIcon(QStyle::SP_DialogOpenButton);
|
||||
QIcon saveIcon = QApplication::style()->standardIcon(QStyle::SP_DialogSaveButton);
|
||||
|
||||
ui->actionOpen->setIcon(openIcon);
|
||||
ui->actionSave->setIcon(saveIcon);
|
||||
|
||||
ui->actionOpen->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
|
||||
ui->actionSave->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QTableWidget>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QMimeData>
|
||||
#include <QShortcut>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
|
@ -30,5 +31,7 @@ private slots:
|
|||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QProgressDialog* progressDialog; // 添加进度对话框指针
|
||||
QMenu* menuFile;
|
||||
QAction* actionFile;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1400</width>
|
||||
<height>21</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuOpen">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
<string>文件(&F)</string>
|
||||
</property>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
|
@ -48,12 +48,15 @@
|
|||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionOpen">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset theme="Save"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
<string>保存</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in New Issue
Block a user