QT学习笔记(2)

来源:互联网 发布:js radio 取值 编辑:程序博客网 时间:2024/05/16 08:31
#include <QAction>#include <QMenuBar>#include <QMessageBox>#include <QStatusBar>#include <QToolBar>#include "mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){    setWindowTitle(tr("王琛的窗口"));    //设置窗口的标题,使用tr函数    //创建QAction对象,图标QIcon,    openAction = new QAction(QIcon(":/images/qt.png"), tr("&Open..."), this);    openAction -> setShortcuts(QKeySequence::Open); //设置快捷键 mac下为cmd + o    openAction -> setStatusTip(tr("Open an existing file"));    //设置状态拦信息    //进行trigger操作调用open操作    connect(openAction, &QAction::triggered, this, &MainWindow::open);    QMenu *file = menuBar() -> addMenu(tr("&File"));    //菜单栏    file -> addAction(openAction);    QToolBar *toolBar = addToolBar(tr("&file"));    //toolbar在哪?    toolBar -> addAction(openAction);    statusBar() ;   //调用此函数才能状态栏显示信息}MainWindow::~MainWindow() {}void MainWindow::open(){    QMessageBox::information(this, tr("Information"), tr("Open"));}

这里写图片描述

原创粉丝点击