![]() ![]() However, for some kinds of form layout, a grid arrangement is much more suitable than a nested arrangement of horizontal and vertical layouts. This kind of layout gives the form designer much more freedom to arrange widgets on the form, but can result in a much less flexible layout. The Grid LayoutĬomplex form layouts can be created by placing objects in a grid layout. However, if you need more control over the placement of objects, consider using the grid layout. Horizontal and vertical layouts can be combined and nested to any depth. Horizontal layouts ensure that the widgets within are aligned horizontally vertical layouts ensure that they are aligned vertically. The simplest way to arrange objects on a form is to place them in a horizontal or vertical layout. Inserting Objects into a Layout Layout Types Horizontal and Vertical (Box) Layouts A blue cursor is displayed in the layout as an object is dragged over it to indicate where the object will be added. Objects can be inserted into an existing layout by dragging them from their current positions and dropping them at the required location. This makes it possible to select a specific layout in a hierarchy, which is otherwise difficult due to the small frame. When a child layout object is selected, its parent layout object can be selected by pressing down the Shift key while clicking on it. ![]() The layout object can be selected and placed within another layout along with other widgets and layout objects to build a layout hierarchy. Its properties (margins and constraints) are shown in the Property Editor. The layout object is indicated by a red frame on the form and appears as an object in the Object Inspector. This is achieved by selecting the objects that you need to manage and applying one of the standard layouts using the main toolbar, the Form menu, or the form's context menu. Layout objects are created by applying a layout to a group of existing objects. Their properties appear below the widget properties of the main form, container widget, or page of a container widget in the Property Editor. Top level layouts are not visible as separate objects in the Object Inspector. The container widget needs to be selected for this to succeed. Similary, top level layouts are set on container widgets ( QGroupBox) or on pages of page-based container widgets ( QTabWidget, QToolBox and QStackedWidget), respectively. To apply a layout, you can select your choice of layout from the toolbar shown on the left, or from the context menu shown below. To check if you have set a top level layout, preview your widget and attempt to resize the window by dragging the size grip. A top level layout is necessary to ensure that your widgets will resize correctly when its window is resized. The form's top level layout can be set by clearing the selection (click the left mouse button on the form itself) and applying a layout. To break a layout, press Ctrl+0 or choose Break Layout from the form's context menu, the Form menu or the main toolbar. For an introduction to the Qt layout system, refer to Layout Management. For example, to achieve a typical dialog layout with a horizontal row of buttons, the dialog elements can be laid out using a vertical box layout with a horizontal box layout containing the buttons at the bottom. Layouts can be nested to form a hierarchy. Spacers can be added to the layout to influence the geometries of the widgets. Once widgets have been inserted into a layout, it is not possible to move and resize them individually because the layout itself controls the geometry of each widget within it, taking account of the hints provided by spacers. ![]() Placing objects in a layout also ensures that they will be resized correctly when the form is resized. This ensures that the objects will be displayed properly when the form is previewed or used in an application. Before a form can be used, the objects on the form need to be placed into layouts. ![]()
0 Comments
Leave a Reply. |