当前位置:网站首页>Qt最基本的布局,创建window界面
Qt最基本的布局,创建window界面
2022-07-26 15:04:00 【AdleyTales】
#include "mainwindow.h"
#include <QMenuBar>
#include <QToolBar>
#include <QStatusBar>
#include <QLabel>
#include <QDockWidget>
#include <QTextEdit>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
resize(400,300);
QMenuBar *menubar = new QMenuBar(this);
setMenuBar(menubar);
QMenu *filename = menubar->addMenu("文件");
QMenu *editmenu = menubar->addMenu("编辑");
QMenu *buildname = menubar->addMenu("构建");
filename->addAction("新建文件");
filename->addAction("打开文件");
filename->addSeparator();
filename->addAction("关闭文件");
editmenu->addAction("恢复");
buildname->addAction("构建所有项目");
// ToolBar
QToolBar *toolbar = new QToolBar(this);
addToolBar(Qt::TopToolBarArea, toolbar);
toolbar->addAction("新建");
toolbar->addSeparator();
toolbar->addAction("打开");
toolbar->addSeparator();
toolbar->addAction("关闭");
// statusbar
QStatusBar *statusbar = new QStatusBar(this);
setStatusBar(statusbar);
QLabel *label = new QLabel(this);
label->setText("状态栏");
statusbar->addWidget(label);
// DockWidgets 浮动窗口 停靠窗口 中心部件的停靠位置
// 验证:浮动窗口是否在中心部件的左侧
QDockWidget *dockWidget = new QDockWidget("小窗口", this);
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
// Center Widget 文本编辑器或浏览器部分
QTextEdit *edit = new QTextEdit(this);
setCentralWidget(edit);
}
MainWindow::~MainWindow()
{
}

边栏推荐
- DICOM学习资料收集
- The practice of software R & D should start from the design
- CVE-2022-33891漏洞复现
- 持续集成(一)基本概念简要介绍
- Google tries to introduce password strength indicator for chromeos to improve online security
- Remote desktop on Jetson nano
- R语言ggplot2可视化:可视化折线图、使用aes函数中的group参数为不同分组可视化折线图
- Parallel d-Pipeline: A Cuckoo Hashing Implementation for Increased Throughput论文总结
- 外文文献查找技巧方法有哪些
- Qt开发高级进阶:如何在显示时适合视窗宽度和高度(fitWidth+fitHeight)
猜你喜欢

Prometheus adds email alarm and enterprise wechat robot alarm

Deep packet inspection using quotient filter paper summary

Double the efficiency of dual screen collaboration lingyao x dual screen Pro leads the new trend of dual screen technology

如何查询外文文献?

Unity URP入门实战

The leader took credit for it. I changed the variable name and laid him off

怎样在nature上查文献?

晋拓股份上交所上市:市值26亿 张东家族企业色彩浓厚

Parallel d-pipeline: a cuckoo hashing implementation for increased throughput

What are the skills and methods of searching foreign literature
随机推荐
Operation method of abbkine elikine human alpha fetoprotein (AFP) ELISA quantitative Kit
The IPO of shengtaier technology was terminated: it was planned to raise 560million yuan, and Qiming and Jifeng capital were shareholders
基于物联网的环境调节系统(ESP32-C3+Onenet+微信小程序)
81.(cesium之家)cesium修改灰色背景(默认蓝色)
FOC电机控制基础
9. Learn MySQL delete statement
Li Hongyi, machine learning 3. Gradient descent
持续集成(一)基本概念简要介绍
外文文献查找技巧方法有哪些
Chapter 08_ Principles of index creation and design
OSPF and mGRE experiments
Advanced Qt development: how to fit the window width and height when displaying (fitwidth+fitheight)
Simulation of character function and string function
哪里有写毕业论文需要的外文文献?
【静态代码质量分析工具】上海道宁为您带来SonarSource/SonarQube下载、试用、教程
How to find undergraduate dissertations of domestic universities?
晋拓股份上交所上市:市值26亿 张东家族企业色彩浓厚
R语言使用lm函数构建多元回归模型(Multiple Linear Regression)、并根据模型系数写出回归方程、使用fitted函数计算出模型的拟合的y值(响应值)向量
Cve-2022-33891 Apache spark shell command injection vulnerability recurrence
MySQL builds master-slave replication