//方法一,将布局中的两个控件设置为0:1
ui->splitter->setStretchFactor(0,0);
ui->splitter->setStretchFactor(0,1);
//方法二,将两个部件设置为窗口的1/3及2/3宽度
ui->splitter->setSizes(QList<int>()<<1/3*width<<2/3*width);
上述两种方法我都试过,都可以很好的设置比例,网上有说第一种设置没有效果,没有想明白,反正都可以尝试一下
//方法一,将布局中的两个控件设置为0:1
ui->splitter->setStretchFactor(0,0);
ui->splitter->setStretchFactor(0,1);
//方法二,将两个部件设置为窗口的1/3及2/3宽度
ui->splitter->setSizes(QList<int>()<<1/3*width<<2/3*width);
上述两种方法我都试过,都可以很好的设置比例,网上有说第一种设置没有效果,没有想明白,反正都可以尝试一下