Qt的最近访问文件问题
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?