Qt - installing layout manager on window
In the C++ GUI Programming with QT
book, it mentions the following 开发者_JAVA百科regarding QWidget::setLayout()
: When called, it installs the layout manager on the window.
What does that mean?
Thanks.
When you do GUI programming, you can use static coordinates to push your UI component, such as button, list, input edit, etc, onto a widget, but it really not a good choice because if your GUI application can change the area size, you must re-calculate every coordinates for each UI components by yourself and move them to the correct position.
That's why Layout Manager comes out. There is many kind of Layout Manger you can choose, and each of them can re-arrange the UI components for you automatically, of course, with different policy you can customize them.
And a QWidget, which usually a window, can call its member function setLayout()
to install a layout manager created/customized by you into the QWidget object. After that, this layout will manage the UI arrange action automatically for you. The parameter to setLayout()
should be the layout manager you want to install into the QWidget object.
精彩评论