Wiki Markup |
---|
{alias:qtrace} |
Name
qtrace — connect widget and Tcl variable
...
Note |
---|
Assigning a value to a trace-variable may result in the corresponding widgets callback function being called. Use qblockedtrace to create a trace variable without this effect. |
Arguments
widget
The widget
...
to which the variable will be connected. If this argument is omitted the current widget will be used. This must be an instance of qlineedit, qlabel, qtextedit, [QTextEdit, qcheckbox, qradiobutton, qspinbox, qdoublespinbox, qhslider, and qvslider.
variable
The name of the variable. The variable should be global or exist in a namespace. When referring to a namespace variable the namespace name should be part of the argument, like "MyNamespace::my_variable".
Examples
Ex.1: QTrace
Anchor | ||||
---|---|---|---|---|
|
No Format | ||||
---|---|---|---|---|
| ||||
set w [qwidget ]
qsetwindowtitle "Variable tracing"
# Create text editor and "Show Text" button.
set layout [qhboxlayout $w]
set label [qlabel "First Name :"]
qaddwidget $layout $label
set lineedit [qlineedit]
qaddwidget $layout $lineedit
# Connect contents of line edit to variable 'name'
qtrace $lineedit name
# Set Tcl variable - this will automatically set the
# text in the line edit to 'Jon'
set name Jon
qshow $w
|
...