VS2019+QT5.12.3学习(2)

这篇博客介绍了在VS2019环境下,结合QT5.12.3如何进行手动和可视化布局。通过创建Qt Class和Qt Widgets Class,利用QT Designer进行拖曳布局,并详细讲解了从界面布局保存为.ui文件,再到生成代码的步骤,以及布局中的size hint、size policy和stretch factor等关键参数。
摘要由CSDN通过智能技术生成

手工布局: Test2_1

添加类为:Qt Class

//myproject.h文件
#pragma once

#include <QWidget>
#include <QLineEdit>
#include <QPlainTextEdit>
#include <QPushButton>

class myproject : public QWidget
{
	Q_OBJECT

public:
	myproject(QWidget *parent);
	~myproject();
private:
	QLineEdit* m_Line;
	QPlainTextEdit* m_Plain;
	QPushButton* m_Push;

};
//myproject.cpp文件
#include "myproject.h"
#include <QHBoxLayout>
#include <QVBoxLayout>

myproject::myproject(QWidget *parent)
	: QWidget(parent)
{
	m_Line = new QLineEdit(this);
	m_Plain = new QPlainTextEdit(this);
	m_Push = new QPushButton(this);
	m_Push->setText("OK");

	//layout为一个局部变量(以后不会再使用),而非成员变量(定义在头文件里,以后可能还会被调用)
	QHBoxLayout* layout1 = new QHBoxLayout;
	layout1->addWidget(m_Line);
	layout1->addWidg
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值