Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{alias:qaddlayout}
h2. Name

*qaddlayout* — add layout to another layout

h2. Syntax
{panel:|borderStyle=solid|borderWidth=1|bgColor=#FFFFAA}
*qaddlayout* _parentboxlayout childlayout_ \[_stretch_]

*qaddlayout* _parentgridlayout childlayout row column_ 

*qaddlayout* _parentgridlayout childlayout row column rowspan columnspan_ 

{panel}

h2. Description

The qaddlayout command adds a layout to another layout according the layout policy of the receiving layout. This command is used when [nesting layouts|http://geocap.onconfluence.com/display/ref/QTcl#QTcl-Example14.NestedLayouts]. 


h2. Arguments
_parentboxlayout_
{indent}An instance of [QHBoxLayout] or [QVBoxLayout]. This is the layout that will contain the child layout to be added.{indent} 

_childlayout_
{indent}The layout to be added to the parent layout. This can be any type of layout.{indent} 

_parentgridlayout_
{indent}An instance of [QGridLayout], acting as the receiving layout.{indent} 

_row_
{indent}The row in the receiving [QGridLayout] where the child layout will be positioned.{indent} 

_column_
{indent}The column in the receiving [QGridLayout] where the child layout will be positioned.{indent} 

_stretch_
{indent}Stretch factor. An integer, this argument determines the layout's ability to stretch during resize. Use this to set preference to which layout(s) in a group should stretch. A value of 100 usually ensures that the given layout will be stretched rather than the other child layouts in the same containing layout.
{indent} 

h2. Examples

h3.  Nested Layouts

{noformat:|borderWidth=1|bgColor=#eeeeee}
set w [qwidget]
qsetwindowtitle "Nested Layouts"

# Main vertical layout for the toplevel window
set mainlayout [qvboxlayout $w]

set label [qlabel "<html>This label is added <em>directly</em> to the vertical layout</html>"]
qaddwidget $mainlayout $label

# Add OK and Cancel buttons in a separate horizontal layout
# Add this layout to main layout
set buttonlayout [qhboxlayout ]
qaddlayout $mainlayout $buttonlayout

set ok_button [qpushbutton OK]
qaddwidget $buttonlayout $ok_button

set cancel_button [qpushbutton Cancel]
qaddwidget $buttonlayout $cancel_button

qshow $w

{noformat}

!att:_img_cmd^nested_layouts.png!

The above example shows two buttons arranged in their own horizontal layout, which is added to the main vertical layout using the [qaddlayout] command.

{pagebreak}