![]() In the constructor we call setContentsMargins() to set the left, top, right and bottom margin. : m_hSpace(hSpacing), m_vSpace(vSpacing) SetContentsMargins(margin, margin, margin, margin) įlowLayout ::FlowLayout( int margin, int hSpacing, int vSpacing) : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) We start off by looking at the constructor: FlowLayout ::FlowLayout( QWidget *parent, int margin, int hSpacing, int vSpacing) doLayout() lays out the layout items, while the smartSpacing() function calculates the spacing between them. We also declare two private methods, doLayout() and smartSpacing(). These functions add items to the layout and handle their orientation and geometry. We reimplement functions inherited from QLayout. Int smartSpacing( QStyle ::PixelMetric pm) const Int doLayout( const QRect &rect, bool testOnly) const Qt ::Orientations expandingDirections() const class FlowLayout : public QLayoutįlowLayout( QWidget *parent, int margin = - 1, int hSpacing = - 1, int vSpacing = - 1) įlowLayout( int margin = - 1, int hSpacing = - 1, int vSpacing = - 1) It is a custom layout class that arranges its child widgets horizontally and vertically. We will only document the definition and implementation of FlowLayout below. The Flowlayout class mainly uses QLayout and QWidgetItem, while the Window uses QWidget and QLabel. The items are first laid out horizontally and then vertically when each line in the layout runs out of space. The Flow Layout example demonstrates a custom layout that arranges child widgets from left to right and top to bottom in a top-level widget.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |