The following quote is from this link: http://doc.qt.io/qt-5/qwidget.html#setLayout
If there already is a layout manager installed on this widget, QWidget won't let you install another. You must first delete the existing layout manager (returned by layout()) before you can call set开发者_StackOverflow社区Layout() with the new layout.
Question 1: What does it mean when you say is "layout manager is installed on this widget"?
Question 2: This link: http://doc.qt.io/qt-5/layout.html shows that there are various forms of layouts like: Horizontal, Vertical, Form Layouts. Grid layout can alone be used to arrange the widgets in the forms supported by other three layouts. Is there any special use of the other three layouts?
A layout is "installed" in a widget when you set it as the widget's layout with setLayout
. That's all it means.
As for what layouts to use: use the simplest layout that does the job you want. Use nesting (you can add a layout to another layout) to make more complex designs. A grid is not necessarily the easiest to use - you'll soon find yourself with headaches about widgets needing to span multiple rows/columns, spacing difficulties etc... if use a single grid as your layout.
精彩评论