2

I have 2 widgets(buttons) in the same splliter and i want to replace the first one with Tabwidget.. i lose the right stretch factor (1:1) it will be like (2:1) or not like the old factor (when it's just 2 buttons)

splitter->addwidget(qbut1);
splitter->addwidget(qbut2);
splitter->insertwidget(0,tab);

and even when i add at the first one tab and one button..tab takes size more than button how can i make it (1:1) i try

splitter->setStretchFactor(0,1);
splitter->setStretchFactor(1,1);

but it doesn't work

4

1 回答 1

2

您可以使用 设置拆分的大小QSplitter::setSizes。要实现一对一的比率,您可以使用以下内容:

int width = splitter->width();
QList<int> sizes;
sizes << width/2 << width/2;
splitter->setSizes(sizes);

请注意,这仅设置初始大小,用户仍然可以随意调整它们的大小。另外,重新阅读有关拉伸因子的文档,听起来好像您可能误解了它们的含义。

于 2015-05-29T15:10:35.830 回答