其他分享
首页 > 其他分享> > QT QSplitter设置初始比例setStretchFactor失效解决

QT QSplitter设置初始比例setStretchFactor失效解决

作者:互联网

QSplitter如下为常用 设置显示比例

1 pRightSplitter=new QSplitter(Qt::Vertical);
2 pRightSplitter->setMouseTracking(true);
3 pRightSplitter->setStretchFactor(0,8);
4 pRightSplitter->setStretchFactor(1,2);
但是由于内部有子窗口的布局时,会失效

使用下面方法设置

1 //pRightTopWidget 为子窗口1
2 QSizePolicy rightTopPolicy = pRightTopWidget->sizePolicy();
3 rightTopPolicy.setVerticalStretch(8);
4 pRightTopWidget->setSizePolicy(rightTopPolicy);
5 //pRightDownWidget 为子窗口2
6 QSizePolicy rightDownPolicy = pRightDownWidget->sizePolicy();
7 rightDownPolicy.setVerticalStretch(2);
8 pRightDownWidget->setSizePolicy(rightDownPolicy);
参考 https://blog.csdn.net/baidu_33850454/article/details/80845582
————————————————
版权声明:本文为CSDN博主「剑峰随心」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_36190978/article/details/103244087

标签:QT,setStretchFactor,rightDownPolicy,QSplitter,pRightDownWidget,pRightSplitter,ri
来源: https://www.cnblogs.com/yuyuanbaobei521/p/14845933.html