QTcl - qt/kde widgets for tcl
QTcl - tcl interpreter integration for Qt/KDE
qtcl ist THE tool to connect state of the art cross platform gui design with the power of tcl as scripting language for prototypes and small projects
- simple interpreter object for embedding or qtcl-shell
- handles all qt/KDE objects not only objects created by the interpreter
- full introspection for all objects
- integrates xml-based gui descriptions generated by gui-designer
- factorys for widgets, actions and layouts etc
- implementations for fileevent and after
- implementation for event receiver and bindings
- debug console and/or shell
- simple extensions
- works with Qt3/KDE3 and tcl from 7.3 upwards
- works with unicode (if using tcl8.4 or younger)
- no need for tk functions or library
- some widget examples included
- easy to use and extend framework for wrapping Qt objects and their methods
this is version 1.2.0
From Version 1.0
- Removed minitcl - (sold separately) :).
- Added class and global method invocation
- Now works with gcc4.0 and qt3.3.4
for deployment
- tcl8.4 or 8.5
- qt3
- kde3 packages if wanted
for building additional
- gcc3 or gcc4, make, binutils, glibc-devel
- tcl8.x-devel
- packages qt3-devel/qt3-devel-doc/qt3-devel-tools
- kde3-devel if wanted
the package can be downloaded from:
http://www.bj-ig.de/qtcl or
http://sf.net/projects/qtcl
extract the archive file run:
./configure:
make
make install (as root)
Concepts
the complete embedding of qt commands in the tcl interpreter needs only one command:qt.
it hides all the Qt things from the global namespace and permits the coexistence with many other
tcl extensions.
pathnames
The basic concept of qtcl is the conversion from pathesnames to objectpointers
and vice versa. So if you create an Object on Qt/KDE f.e.: QObject *o=new QObject(0,"otto");
you can find the object with the name .otto.
This concept is nearly the same as in tk but works here not only for widgets
but also for all objects regardlesss of created by qtcl or other
Qt functions.
pathnames are treated as .-separated lists of parents with . as root.
.top.xx.yy means an object with the name yy as child of an object
with the name xx as child of an object with the name top with no parent.
pathnames while creating objects
if objects are created, the given pathname is separated in two parts:
the parent name (everything left of the last point in the path) - it must refer to an existing object
sometimes this object needs to be derived from a specialized class. (like QWidget, QLayout etc.)
and the new name (the part after the last point in path) which must not exist as
object in this parent (or root). If the parent name is '.' the objectRoot is implied.
properties/methods/slots/signals
these things are concepts of Qt (see documentation there).
The qt command
- qt create classname newpath options
creates an new object with class and path
- qt objects [-class class] [-deep]
gives a list of known objects
- qt .obj.ect.path method args
searchs the object by path and calls method with args
- qt .obj.ect*name method args
searchs the object by start path and personal name and calls method with args
- qt *name method args
searchs the object by personal name and calls method with args
- qt Classname method args
searchs the class Classname and calls the class method with args
- qt load filename [parentpath]
loads an .ui-file (from designer) and builds up the complete ui inside
- qt build string [parentpath]
uses the string as .ui-file (xml-gui-tree from designer) and builds up the complete ui inside
QObject
objects can be refered to by there pathname. Valid versions are:
qt .top the rootobject with the name top
qt .top.okbutton the object with the name okbutton in the parent with the name top or
qt .top*okbutton the object with the name okbutton in the object with the path .top
valid methods for all objects are:
- qt objectpath set [property value]...
sets the properties in the list to the values in the list (for the concept of properties refer to
the qt documentation)
- qt objectpath get property
gets the value of the given propertie
- qt objectpath name
gets the name of the object
- qt objectpath class
gets a list of the classnames of the object from Objectclass to QObject
- qt objectpath inherits classname
tests for inheritance of classname. if the object implements classname, the method returns true else false.
- qt objectpath parent
returns the pathname of the parent or the empty string 'no parent'
- qt objectpath children [-deep]
the result is the list children as pathnames. if deep is specified, then
also the childs of the childs are appended and so on.
- qt objectpath query [-exact] [-flat] [-class classname] [-name name]
the result is a list children as pathnames that matches the conditions
- qt objectpath slots/signals/properties/methods [-self]
returns a list of slots/signals/properties/methods for this object - optionally only the slots for the
special class
- qt objectpath connect signalname objectpath slot
connects signalsname with object refered by objectpath and slotname
- qt objectpath disconnect [signalname]
disconnects the complete object or the signal with the name signalname
- qt objectpath bind [ signalname [ script] ]
shows all bindings for object (without args) or
shows the binding source for signalname or
binds signalname to script
if script is empty the binding is removed
(in the script are arguments to the signal function
are refered to by %0..%9 and the sender object is refered to by %w)
- qt objectpath event script
sends all events for object to script
- qt objectpath register [-deep]
creates commands in the interpreter for the objects and its childs if
deep is specified. The name of the command is the pathname of the object.
- qt objectpath slotname [args..]
invokes slotfunctions of the object with the given args
- qt objectpath [nothing]
gives a list of all possible methods
QWidget
widgets are created by the command:
qt widget typename path options
typename is an valid Classname derived from QWidget
pathname is pathname as described above.
options are pairs of properties with values
the widget will be created using the widgetFactory methods from qt
(see documentation there).
Example:
qt create QDialog .top sizeGripEnabled true % creates a QDialog
qt create QPushButton .top.okbutton text ok % creates a button
qt .top show % invokes slot show
special QWidget methods:
- qt widgetpath toplevel
gives the pathname of the toplevel for widgetpath
- qt widgetpath tooltip [string]
gets/sets the tooltip for widget
- qt widgetpath setTabOrder nextwidget
sets the tabOrder
special QDialog methods:
- qt widgetpath result
gives boolean result of the dialog
more methods for specialized widgets exist. the qt widgetpath method
gives a list of all possible methods for this object.
QLayout
layout are created by the command:
qt create typename path options
typename is an valid Classname derived from QLayout
pathname is pathname as described above.
options are pairs of properties with values
the layout will be created using an layoutfactory.
Example:
qt create QDialog .top % creates a QDialog
qt layout QGridlayout .top.grid% creates a QGridlayout
qt widget QTextEdit .top.e% creates a QTextEdit
qt .top.grid add .top.e -row 0 -column 0% adds edit to grid
special QLayout methods:
- qt layoutpath add widgetpath
adds widgetpath to layout
- qt layoutpath invalidate
forces recalculation of layout
special QGridLayout methods:
- qt layoutpath add widgetpath [-row n] [-col n] [-rowspan n] [-colspan n] [-torow n] [-tocolumn n]
adds widgetpath to layout
- qt layoutpath rowstretch row [value]
gets or sets rowstretch for row
- qt layoutpath colstretch row [value]
gets or sets colstretch for column
special QBoxLayout methods:
- qt layoutpath insertWidget [-stretch n] [-alignment a] [-at n] [-pos pos] widgetpath
adds widgetpath to layout
- qt layoutpath insertSpacing [-stretch n] [-alignment a] [-at n] [-pos pos] size
adds space with size to layout
- qt layoutpath insertStretch [-stretch n] [-alignment a] [-at n] [-pos pos]
adds stretch to layout
to get a list of all possible methods use qt layoutpath.
to get a list of all possible action classes use qt layout.
QAction
actions are created by the command:
qt create typename path options
typename is an valid Classname derived from QAction
pathname is pathname as described above.
options are pairs of properties with values
the action will be created using an actionfactory.
Example:
qt widget QMenuBar .top.menubar % creates a menubar
qt action QAction .top.fileopenaction% creates a QAction
qt .top.fileopenaction addTo .top.menubar% adds action to menubar
special QAction methods:
- qt actionpath addTo widgetpath
adds this action to widget
- qt actionpath removeFrom widgetpath
removes this action from widget
to get a list of all possible methods use qt actionpath.
to get a list of all possible action classes use qt action.
please refer to the examples in the tests directory of the archive
- more documentation
- more examples
- more tests
- more methods
- see also TODO file in the archive
the qtcl package and all accompanying material is:
copyright (c) 2002-2005, peter brueckner - brueckner & jarosch ingenieurgesellschaft mbh erfurt germany
this package is released under the GPL. please refer to to this license for information on usage and distribution of this package, and for a disclaimer of all warranties.
please send questions, comments, bug reports, patches, requests to:
Peter Brueckner<peter@bj-ig.de>
copyright (c) 2002-2005 brueckner & jarosch <http://www.bj-ig.de>