我需要计算QGroupBox的确切宽度。我有它的孩子的宽度,但我很难计算QGroupBox装饰的宽度(意思是total_size - children_size - layout_space
)。组框在QBoxLayout中只有一个孩子。QGroupBox装饰的大小
目前我做的方式如下:
int width = layout()->contentsMargins().left() +
layout()->contentsMargins().right() +
6; // <--- magic number
width += child->maximumWidth();
我得到了“6”的试错和它的作品在我的系统的风格(KDE的氧),但我想获得它独立平台的方式。
有什么方法可以获得它?
幻数来自布局的layoutSpacing属性。 – Anton 2012-04-20 21:25:01