开发者

Is there something similar to GTK+'s GtkSizeGroup in Qt?

GTK+ has a widget called GtkSizeGroup which is used to synchronize the sizes of widgets that don't have the same parent. Is there a similar widget in Qt?

开发者_运维知识库

UPDATE The parents of the widgets are different. I have 2 groupboxes, and there are labels / QLineEdits inside. I'd like to line them up.

+-[ Group1 ]----------------------+
|              ------------------ |
| longer label |                | |
|              ------------------ |
+---------------------------------+
+-[ Group2 ]----------------------+
|       ------------------        |
| label |                |        |
|       ------------------        |
+---------------------------------+


If a custom QLayout is a problem (depending on the parenting hierarchy, it might be), you could do this via an eventFilter on resizeEvent - each slave widget would install itself (or a helper) as an event filter on the master widget, and when it sees a resize event, update its own size. How good or badly this works will depend on your specific situation, however.


No, but you could create something similar with a custom QLayout. Also see How to Write A Custom Layout Manager

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜