Qt下设置停靠窗口的大小

在Qt中,QDockWidget作为其子部件的包装器,大小调整应在子部件本身实现。QDockWidget会根据子部件的尺寸提示、最小和最大尺寸及大小策略来调整自身的约束,包括边框和标题。不应直接在QDockWidget上设置尺寸约束,因为这会随停靠状态变化。正确做法是在QDockWidget包含的窗体中设置宽度。
摘要由CSDN通过智能技术生成

A QDockWidget acts as a wrapper for its child widget, set with setWidget(). Custom size hints, minimum and maximum sizes and size policies should be implemented in the child widget. QDockWidget will respect them, adjusting its own constraints to include the frame and title. Size constraints should not be set on the QDockWidget itself, because they change depending on wether it is docked; a docked QDockWidget has no frame and a smaller title bar.(Come From English document).

上面的主要意思是说设置停靠窗口的大小不能在QDockWidget中设置,因为他们的改变取决于是否停靠。所以要设置停靠窗口的大小应该在QDockWidget上放置的窗体本s身中设置。


Example:

//set the width in the child form


//in the child  form constructor I set the width

#include "mywidget.h"

MyWidget::MyWidget(QWidget *pa
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值