2.3 QLayout一探究竟(上)

2.布局
2.1 布局简介
2.2 Qt四大布局介绍及使用方法
2.2.1 QBoxLayout讲解及示例
2.2.1.1 QHBoxLayout介绍
2.2.1.1 QVBoxLayout介绍
2.2.2 QFormLayout讲解及示例
2.2.3 QGridLayout讲解及示例
2.2.4 QStackedLayout讲解及示例

2.3 QLayout一探究竟

2.3.1 布局的基础单元-QLayoutItem
2.3.1.1 QSpacerItem介绍
2.3.1.2 QWidgetItem介绍
2.3.2 布局添加控件的原理分析
2.3.2.1 addWidget和addItem到底做了啥
2.3.2.2 为什么控件可以按照不同的布局进行对应的排布
2.3.2.3 布局中spacing、margin、alignment用法讲解
2.3.3 如何清空部件上的布局
2.3.3.1 如何移除布局上的某个部件
2.3.3.2 如何对部件进行重新布局


2.3 QLayout一探究竟

上篇文章中给大家介绍了Qt中四大布局的基本用法,我个人较常用的是QBoxLyoaut和QGridLayout,很方便搭建出各式各样的界面,另外一点,我建议大家多用代码的方式来搭建布局,方便后期拓展及复用,针对较复杂的页面,我们可以用对界面分模块,及在代码中按照分好的模块创建该模块的控件及布局,如下面示例代码,实现一个简

【QT】QT从零入门教程(十):QT布局管理QLayout   介绍完常用控件之后,我们发现,之前控件的大小位置都是通过resize()、move()来设置的,很不方便,当你修改某个控件的位置时,其他控件也需要进行调整,容易出现牵一发而动全身的情况。   QT提供了类QLayout进行布局管理,能很好解决这一情况。常用的布局管理有QVBoxLayout、QHBoxLayout、QFormLayout、QGridLayout。通过布局嵌套基本可以实现理想的... 阅读详情

相关推荐

Qt——弹簧(QSpacerItem)的妙用

在布局设计中巧妙使用QSpacerItem,效果别有洞天

zhangchuan7758的博客 2万+

2.3 QLayout一探究竟(下)

2.布局2.1 布局简介2.2 Qt四大布局介绍及使用方法2.2.1 QBoxLayout讲解及示例2.2.1.1 QHBoxLayout介绍2.2.1.1 QVBoxLayout介绍2.2.2 QFormLayout讲解及示例2.2.3 QGridLayout讲解及示例2.2.4 QStackedLayout讲解及示例2.3.1 布局的基础单元-QLayoutItem2.3.1.1 QSpacerItem介绍2.3.1.2 QWidgetItem介绍2.3.2。

前行之路还需前行 451

翻翻源码,解决Qt程序问题QLayout: Attempting to add QLayout ““ to xxxx ““, which already has a layout

其他Layout对象如果new的时候指定了父窗口的this作为parent,中间你却在子Widget中setLayout(xxlayout对象),那么Qt就会警告你,父窗口已经有主Layout了,你的代码中还尝试添加一个或多个主Layout,因为这些Layout的this指向了父窗口,但你却用在子窗口上去了。那么结论来了,既然出现错误(警告)之后,Qt框架自身会设置对象的parent为空,也就是说,在我们的代码中,某个地方将layout的parent设置成了别的对象,或是this,或是对象指针。

有问题或资源连接有缺失的可以私信公众号新潮看世界获取 676

Qt中的QLayout:遍历所有子项

在某些情况下,我们可能需要遍历QLayout中的所有子项,以便进行特定的操作或收集信息。本文将介绍如何在Qt中遍历QLayout的所有子项,并提供相应的源代码示例。QLayout可以包含其他QWidget部件,并根据特定的布局算法自动调整它们的位置和大小。通过使用类似的方法,我们可以根据需要对QLayout的子项进行各种操作,例如设置子项的属性、调整子项的大小和位置等。在上面的示例中,我们创建了一个QHBoxLayout布局,并向其中添加了三个QPushButton部件。方法来获取指定索引位置的子项。

EknOcaml的博客 664

探索Vortex开源GPGPU:RISC-V SIMT架构(4-1),Execute SFU(1)

本文详细分析了Vortex RISC-V内核6级流水线中Execute阶段的SFU(特殊功能单元)模块。重点介绍了SFU的数据流结构,包含dispatch_unit、pe_switch、csr_unit、wctl_unit和gather_unit五个子模块。文章深入解析了warp控制指令wspawn和tmc的实现机制:wspawn用于激活指定数量的warp并设置新PC值,tmc则用于控制线程掩码和warp状态。通过C代码和汇编指令的对照分析,阐明了这些指令在并行计算中的关键作用,包括线程激活、状态切换和执行

weixin_55313207的博客 1363

RK3588 Ubuntu 20.04 编译 eglinfo 踩坑实录:从 Python 环境配置到 Mali 驱动调试

本文详细解析了在RK3588平台上使用Ubuntu 20.04编译eglinfo的全过程,包括Python环境配置、waf构建系统升级、Mali驱动调试等关键步骤。通过系统级软链接方案、驱动状态诊断和EGL环境验证技巧,帮助开发者快速解决常见问题,构建可靠的图形调试环境。

weixin_29158047的博客 374

AWS RDS 介绍 三)创建 RDS 实例

AWS RDS 介绍 共分为 7 个部分, 其中 第 3部分重点介绍,如何创建一个RDS 实例。 三) AWS RDS 试用MySQL http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.MySQL.

XuYongshi02的专栏 7646

基于CPCC_S_TASK_LIST_MAINTAIN的工艺路线组件批量分配实战与避坑指南

本文详细解析了SAP PP模块中基于CPCC_S_TASK_LIST_MAINTAIN函数实现工艺路线组件批量分配的实战技巧与避坑指南。针对批量分配的核心挑战,提供了参数配置、BAPI协同使用、Excel导入等解决方案,并分享了大容量数据处理优化经验,帮助用户高效完成工艺路线组件分配任务。

weixin_33563728的博客 306

“华为”云桌面系统声音比较小,如何调大?

调整操作系统声音 开启云桌面,登录账户之后,进入操作系统,鼠标左键点击右下角的声音图标,把声音调到最大(如下图); 可以考虑使用浏览器在线听音乐,确定声音的音量! 如果只是耳麦声音小,可以鼠标右键点击声音图标,选择录音设备(R),如下图: 点击“录音设备(R)”后进入,鼠标右键点击“麦克风”选择属性,将侦听级别调至最大,确定! 调整华为云终端声音(软设置) 将鼠标移至桌面的顶端中间位置,打开如下图的样式图标,鼠标左键点击“主页”; 点击“主页”之后,将回到云桌面的终端操作界面,

shunchang的专栏 2337

保姆级教程:用Cesium的Primitive API实现火箭发射全流程动画(含代码避坑)

本文详细介绍了如何使用Cesium的Primitive API实现火箭发射全流程动画,包括模型控制、关节动画和精细时序管理。通过实战代码示例和性能优化技巧,帮助开发者高效构建高复杂度航天仿真系统,显著提升三维可视化效果与运行效率。

weixin_42565652的博客 212

Fastgpt本地使用Docker Compose 快速部署

修改文件,并执行再执行d重起容器。具体配置,参考配置详解。可以查看日志,在启动容器后,第一次请求网页,会进行配置文件读取,可以看看有没有读取成功以及有无错误日志。进入 FastGPT 容器,可以通过ls data查看目录下是否成功挂载文件。可通过查看配置文件。可能不生效的原因挂载目录不正确配置文件不正确,日志中会提示invalid json,配置文件需要是标准的 JSON 文件。

洛阳泰山的博客 1633

搞懂 SAPUI5 Fiori 应用的 OData 授权维护:从 IWSG、IWSV 到 S_SERVICE 的完整实践

本文探讨了SAP Fiori项目中常见的授权问题及其解决方案。文章指出,开发人员常误将OData服务访问问题归咎于前端代码或配置,而实际上多因授权默认值未正确带入角色所致。详细分析了IWSG(前端服务组元数据)和IWSV(后端业务服务)两个关键对象的作用机制,强调应通过PFCG角色的Authorization Default入口维护服务对象,而非直接修改S_SERVICE授权对象。文章还提供了前后端授权配置的具体操作步骤,并特别提醒需同时配置前端和后端授权,才能确保应用完整可用性。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 206

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 2.1-2.2 Qt布局简介及四大布局的使用
下一篇: 2.3 QLayout一探究竟(下)
前行中的小猪
前行中的小猪 领域专家: C/C++技术领域 领域专家: C/C++技术领域
博客等级 码龄10年 4万+粉丝 134原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值