QT5学习总结

xiaoxiao2021-02-28  55

1.添加资源文件

选中项目,右键–>添加新文件–>QT–>Qt Resource File 填写资源名称名字:img 打开img.qrc,添加前缀 / 点击添加文件,前提是文件在项目工程的目录下

2. QWidget 设置背景色(Style Sheet)

sys_setting_window = new QWidget(this->s_parent); sys_setting_window->move(0,TOP_WINDOW_HEIGHT); sys_setting_window->resize(SCREEN_WIDTH,(SCREEN_HEIGHT-TOP_WINDOW_HEIGHT-BOTTOM_WINDOW_HEIGHT)); sys_setting_window->setAutoFillBackground(true); sys_setting_window->setStyleSheet("border:3px;background-color:white");

3.界面文件mainwindow.ui

QMainWindow 属性:geometry:UI窗口物理大小 WindowTitle窗口标题 去掉标题栏

   ui->setupUi(this); this->setWindowFlags(Qt::FramelessWindowHint);

StyleSheet 样式(同css) 背景图片设置background-image border-image(常用,会自动调整大小) menuBar 菜单栏 (在这里输入添加菜单栏) statusBar 状态栏(主窗口最下言)

4.布局控件

先拖拽控件布局,再往里面添加控件 布局完成后,可进行全局布局,空白处,右键–>布局–>在窗体布局中布局

QPushButton 显示文字,图片(stylesheet) QLineEdit 单行输入文本 QTextEdit 多行输入文本 QPlain TextEdit 多行输入文本 QComboBox 下拉选择框 SPinBox 上下拉数字选择框 QListView 列表项(model, delegate) QListWidget 列表项控件 QTab Widget (Table 页面控件) QWebView 显示网页控件

转载请注明原文地址: https://www.6miu.com/read-2621153.html

最新回复(0)