diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 90825e2392b2d70e43c7a25b8a3752299a933894 (patch) | |
tree | e33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/docs/examples/customwidget | |
download | tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/docs/examples/customwidget')
-rw-r--r-- | kjsembed/docs/examples/customwidget/README | 2 | ||||
-rwxr-xr-x | kjsembed/docs/examples/customwidget/custom_widget.js | 57 |
2 files changed, 59 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/customwidget/README b/kjsembed/docs/examples/customwidget/README new file mode 100644 index 00000000..6100357d --- /dev/null +++ b/kjsembed/docs/examples/customwidget/README @@ -0,0 +1,2 @@ +This example shows how scripts can create widgets directly. It creates +and displays the window shown in customwidget.png. diff --git a/kjsembed/docs/examples/customwidget/custom_widget.js b/kjsembed/docs/examples/customwidget/custom_widget.js new file mode 100755 index 00000000..dbab2d8f --- /dev/null +++ b/kjsembed/docs/examples/customwidget/custom_widget.js @@ -0,0 +1,57 @@ +#!/usr/bin/env kjscmd + +// +// Script demonstrating how to create a custom widget. +// + +function createField( parent ) +{ + var hbox = new QHBox( box, 'hb' ); + + var label = new QLabel( hbox ); + label.text = 'Filename:'; + var ed = new QLineEdit( hbox, 'lineed' ); + ed.text = './my_file.txt'; + var pb = new QPushButton( hbox, 'button' ); + pb.text = 'Br&owse'; + var led = new KLed( hbox, 'led' ); +} + +function createGroup( parent ) +{ + var grp = new QGroupBox( box, 'grp' ); + grp.columns = 1; + grp.title = 'A QGroupBox'; + + var cb1 = new QCheckBox( grp, 'check1' ); + var cb2 = new QCheckBox( grp, 'check2' ); + cb1.text = 'Check Box One'; + cb2.text = 'Check Box Two'; + + return grp; +} + +// Outer layout +var box = new QVBox(); +box.margin = 6; + +// Title +var ttl = new QLabel( box, 'title' ); +ttl.text = '<qt><center><h3>KJSEmbed Object Creation Demo</h3></center><hr></qt>'; + +// Named field +createField( box ); + +// Text editor +var l = new QLabel( box, 'tl' ); +l.txt = 'Editable Text Widget:'; +var txt = new QTextEdit( box, 'text_edit' ); +txt.text = '<qt>This is an editable text widget created from <i>Javascript</i> using the ' + + '<b>KJSEmbed</b> library. As you can see, the facilities are powerful enough ' + + 'for many useful applications to be found.</qt>'; + +// Group of check boxes +var grp = createGroup( box ); + +box.show(); +application.exec(); |