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