上一讲: qt5.15 步步走-1.认识qt程序;
我将从 官方示例 入手,讲解qt的特性和知识点。根据自己的安装找到 Examples ,后面子目录我们是一样的。
示例:
D:qtExamplesQt-5.15.1widgetstutorialswidgetswindowlayout
QWidget window;
//! [create, lay out widgets and show]
QLabel *label = new QLabel(QApplication::translate("windowlayout", "Name:"));
QLineEdit *lineEdit = new QLineEdit();
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget(label);
layout->addWidget(lineEdit);
window.setLayout(layout);
//! [create, lay out widgets and show]
window.setWindowTitle(
QApplication::translate("windowlayout", "Window layout"));
window.show();
窗口中有两个组件:
- QLabel 可以容纳字体显示,图片,动图等;
- QLineEdit 可输入文字的文本框
小组件以后慢慢练习,这里出现一个重要特性: 布局
QHBoxLayout是布局的一种&#