Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Wiki Markup
{alias:qadjustsize}

Name

qadjustsize — Adjust widget size to contents

...

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

...