slot_backBtn_clicked()
{
qDebug()<<"slot_backBtn_clicked";
}
Qt 56样例:
MainWindowh:
#ifndef MAINWINDOW_H#define MAINWINDOW_H
#include <QObject>
#include <QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget parent = 0);
~MainWindow();
private:
void initialAction();
void initialMenuBar();
void initialToolBar();
void initialStatusBar();
void open();
QAction openAction;
};
#endif // MAINWINDOW_HMainWindowcpp:#include <QAction>
#include <QMenuBar>
#include <QMessageBox>
#include <QStatusBar>
#include <QToolBar>
#include "MainWindowh"
MainWindow::MainWindow(QWidget parent) :
QMainWindow(parent)
{
setWindowTitle(tr("Main Window"));
initialAction();
initialMenuBar();
initialToolBar();
initialStatusBar();
}
MainWindow::~MainWindow()
{
}
void MainWindow::initialAction()
{
openAction = new QAction(QIcon(":/images/doc-open"), QObject::tr("&Open"), this);
openAction->setShortcuts(QKeySequence::Open);
connect(openAction, &QAction::triggered, this, &MainWindow::open);
}
void MainWindow::initialMenuBar()
{
QMenu file = menuBar()->addMenu(QObject::tr("&File"));
file->addAction(openAction);
}
void MainWindow::initialToolBar()
{
QToolBar toolBar = addToolBar(QObject::tr("&File"));
toolBar->addAction(openAction);
}
void MainWindow::initialStatusBar()
{
statusBar();
openAction->setStatusTip(QObject::tr("Open an existing file"));
}
void MainWindow::open()
{
QMessageBox::information(this, tr("Information"), tr("Open"));
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)