Make QFormLayouts inside multiple QGroupboxes have

2019-04-10 09:02发布

问题:

I have a dialog in qt that has multiple groupboxes, each using a form layout. Something like this: https://dl.dropbox.com/u/4494367/Groupbox_Layouts.png

Is there a way to get the form layouts to link, so that the have the same column widths?

回答1:

There is no built in way to do this but three possibilities come to mind:

  • Manually set the minimum width on all your labels to a value that will accommodate the longest of all of your labels (not flexible). Suggested here in a similar question.
  • A variation of the above would be to try to query the size hints to find the largest label and then set the minimum widths on all your labels based on that. This suggestion comes from an answer to another similar question here.
  • Write a custom layout that might do something similar to the above.

You may want to browse the linked questions for other info but I think it is generally agreed that this objective may not be entirely worth the effort :)



标签: qt4