Qt的最近访问文件问题

a15630176380 2017-09-01 02:30:39
void MainWindow::createActions()
{
newAction=new QAction(tr("&New"),this);//动作new有一个加速键NEW,和一个父窗体(主窗口)
// newAction->setIcon(QIcon);
newAction->setShortcut(QKeySequence::New);//快捷键枚举
newAction->setStatusTip(tr("Create a new spreadsheet file"));
connect(newAction,SIGNAL(triggered()),this,SLOT(newFile()));
for(int i=0;i<MaxRecentFiles;++i)这个数组里面放的是动作?不应该是最近显示的文件名吗?
{
recentFileActions[i]=new QAction(this);
recentFileActions[i]->setVisible(false);
connect(recentFileActions[i],SIGNAL(triggered()),this,SLOT(openRecentFile()));
}
closeAction=new QAction(tr("&Close"),this);
closeAction->setShortcut(QKeySequence::Close);
closeAction->setStatusTip(tr("Close this window"));
connect(closeAction,SIGNAL(triggered()),this,SLOT(close()));
exitAction=new QAction(tr("E&xit"),this);
exitAction->setShortcut(tr("Ctrl+Q"));//设置快捷键
exitAction->setStatusTip(tr("Exit the application"));//设置提示语
connect(exitAction,SIGNAL(triggered()),qApp,SLOT(closeAllWindows()));

selectAllAction=new QAction(tr("&All"),this);//表示选择全部快捷键为ctrl+A
selectAllAction->setShortcut(QKeySequence::SelectAll);//设置快捷键 QKeySequence:键序列
selectAllAction->setStatusTip(tr("Select all the cells in the"
"spreadsheet"));
connect(selectAllAction,SIGNAL(triggered()),spreadsheet,SLOT(selectAll()));

//Show Grid是一个复选(checkable动作)
showGridAction =new QAction(tr("&Show Grid"),this);
showGridAction->setCheckable(true);
showGridAction->setChecked(spreadsheet->showGrid());
showGridAction->setStatusTip(tr("show or hide the spreadsheet ' s grid"));
connect(showGridAction,SIGNAL(toggled(bool)),spreadsheet,SLOT(setShowGrid(bool)));

aboutQtAction=new QAction(tr("About &Qt"),this);
aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
connect(aboutQtAction,SIGNAL(triggered()),qApp,SLOT(aboutQt()));//通过访问qApp这个全局变量
//我们可以使用QApplication对象的aboutQt槽,目的是为了弹出一个对话框。
}

刚刚学Qt 按照书本上打的代码,我的理解应该是数组里面保存的是最近访问的文件名啊,为什么是保存Action?
...全文
254 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xvwenqiang 2019-12-09
  • 打赏
  • 举报
回复
您好,可以贴出全部代码吗?

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧