Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Name

qadjustsize — Adjust widget size to contents

Syntax

Panel
bgColor#FFFFAA
borderWidth1
borderStylesolid

qadjustsize [widget]

Description

The qadjustsize command tells the widget to recalculate its geometry based on its contents. This command is often used to perform a size adjustment to windows that has had its interior changed, usually as a result of widgets being removed or added after the widget's initial display.

The qadjustsize is not always needed. QTcl will resize widgets quite well on its own without an explicit call to qadjustsize.

See also qresize and qsetfixedsize. These commands use pixel based size-specifications.

Arguments

widget

Target widget. If not given the current widget is used.

Examples

Ex.1: Window size adjustment

No Format
bgColor#eeeeee
borderWidth1
# Callback procedure for "Hide" button - hides the label
proc hide_label {} {
    qhide $::label
    qadjustsize $::w
}

# Callback procedure for "Show" button - redisplays the label
proc show_label {} {
    qshow $::label
    qadjustsize $::w
}

# Create toplevel window
set w [qwidget ]
qsetattribute $w deleteonclose

set layout [qgridlayout $w]

# Create two buttons for showing and hiding a label (created later)
set hide_button [qpushbutton "Hide Label" hide_label]
qaddwidget $layout $hide_button 0 0

set show_button [qpushbutton "Show Label" show_label]
qaddwidget $layout $show_button 1 0

# Create label to be shown or hidden by buttons.
set label [qlabel "Label"]
qaddwidget $layout 0 1 

qshow $w

{noformat}

!att:_img_cmd^qadjustsize.png!
_ _

Image Added
_ _