Qt基础 10_MainWindow
来源:互联网 发布:军粮 知乎 编辑:程序博客网 时间:2024/05/16 09:59
/**********************************
* 课程名 :QT编程
* 时 间 :2017年6月5日(周一)下午
* 工程名 :12 MainWindow
* 类 名 :mainWindow
* 内 容 :MainWindow
* CSDN :Qt基础 10_MainWindow
**********************************/
一、MainWindow基础操作 之 添加资源文件
步骤一:新建资源文件
步骤二:添加前缀,将默认路径改为/img
步骤三:添加需要使用的图片文件
二、MainWindow基础操作 之 菜单条
自动版:
1、菜单及菜单项:在ui界面直接输入即可
2、图标
手动版:在构造函数中
1、菜单及菜单项:
QMenu *pm = new QMenu("手动设计菜单1");pm->addAction(icon,"手动菜单项1");this->menuBar()->addMenu(pm);
2、图标
相对路径方式,用文件夹中的icon
QIcon icon("D:/QT/icon1.jpg");
用资源文件 —— 格式:”:/前缀/文件相对于资源的路径/文件名”
QIcon icon(":/img/icon1.jpg");
3、添加功能
QAction *qa = new QAction(icon,"手动菜单项2,关闭",0); pm->addAction(qa); connect(qa,SIGNAL(triggered()),this,SLOT(close()));
三、MainWindow基础操作 之 工具条ToolBar
**自动版:**ctrl + 拖拽菜单项
手动版:
//定义手动菜单项QAction *qa = new QAction(icon,"手动菜单项2,关闭",0);//添加手动菜单项到工具栏ui->mainToolBar->addAction(qa);//添加新工具条QToolBar *toolbar = new QToolBar("手写新工具条",this);//将菜单项qa加入其中this->addAction(qa);//使其在右方addToolBar(Qt::RightToolBarArea , toolbar);
四、MainWindow基础操作 之 状态栏statusBar
//显示指定时间的指定信息 ui->statusBar->showMessage("显示给定的Message5秒",5000);
//显示信息 QLabel *label = new QLabel("我是Label"); ui->statusBar->addWidget(label);
四、MainWindow基础操作 之 中心窗QLineEdit
QLineEdit *lineEdit = new QLineEdit("QLineEdit"); this->setCentralWidget(lineEdit);
源代码:download.csdn.net/download/c_estbon/9867033
阅读全文
0 0
- Qt基础 10_MainWindow
- QT基础
- qt基础
- qt基础
- Qt 基础
- qt基础
- QT基础
- qt基础
- qt基础
- QT基础
- qt基础
- qt基础
- qt基础
- Qt基础
- Qt基础 - Qt Layout Management
- Qt基础之hello qt
- QT:Qt 网络编程基础
- QT的打印基础
- 整合SSM框架,启动时报错java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonProcessingException
- JDBC进阶功能2
- Oracle 定义变量总结
- 兄弟选择器
- String、StringBuffer和StringBuilder
- Qt基础 10_MainWindow
- JAVA生成Word文档
- Java 多线程中关于 ExecutorService 和 CompletionService的讨论
- [es6] let & const
- 51NOD1433:0和5(数论)
- H5自测题5
- 微型技术博客-SWing界面跳转。
- 中位数
- 使用IntelliJ IDEA 配置Maven