Wiki Markup |
---|
{alias:qdestroyed} |
Name
qdestroyed — catch widget destruction
...
Deleting a widget is not the same as closing it. Closing in itself just renders the widget invisible, while still retaining the widget in the computers memory for later redisplay. Deleting a widget removes the widget entirely from memory, requiring that the widget be re-created in order to be redisplayed. A widget is always closed before it is deleted.
Arguments
widget
The widget for which we want to catch the destruction event. This can be any widget or qaction .
cmds
Tcl statements to be executed when the widget is destructed. This will often be the name of a Tcl procedure. The widget's children are destroyed immediately after these commands are processed.
Examples
Ex.1: Catching a destruct event
...
No Format | ||||
---|---|---|---|---|
| ||||
#
# Procedure to be called when the widget is destructing.
#
proc killed {} {
puts "Object destroyed"
}
set w [qwidget]
# This is needed for the widget to be deleted when closing
qsetattribute $w deleteonclose
# Assign the 'killed' procedure as destruction-callback
qdestroyed $w killed
qshow $w
|
...