summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/kjsuic/kjsuic.js
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/docs/examples/kjsuic/kjsuic.js
downloadtdebindings-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/kjsuic/kjsuic.js')
-rw-r--r--kjsembed/docs/examples/kjsuic/kjsuic.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/kjsuic/kjsuic.js b/kjsembed/docs/examples/kjsuic/kjsuic.js
new file mode 100644
index 00000000..f95aa5ee
--- /dev/null
+++ b/kjsembed/docs/examples/kjsuic/kjsuic.js
@@ -0,0 +1,47 @@
+/*
+* To use this fuction provide the ui file name, the parent
+* that will handle the slots of the form, and the parent
+* widget that will handle the UI portion.
+*
+* var form = kjsuic("EnvelopeMakerUI.ui", this, this);
+* println(dump(form));
+*
+* This will then return you a widget object that has properties
+* that are the main child widgets in the UI file. So if you have
+* a KLineEdit called "myLineEdit" in the UI file then there would
+* be a member of the form called myLineEdit. (ex: form.myLineEdit )
+*
+* If there are container widgets present then the children will show
+* up as properties of those widgets. So if you have a groupbox called
+* "Group" and a KLineEdit inside of it called "editor" you would address
+* this as "Group.editor".
+*
+* An important note: Take care when using UI files with this that have
+* widget names that do not conflict with current Qt properties as the Qt
+* properties will take precident over the added widgets.
+*/
+
+function kjsuic(uifile, slotParent, parent)
+{
+ var widget = Factory.loadui(uifile, slotParent, parent);
+ var lst = widget.children();
+ addChildren( widget )
+ return widget;
+}
+
+function addChildren( widget )
+{
+ var lst = widget.children();
+ for( var idx = 0; idx < lst.length; ++idx)
+ {
+ var str = "widget." + lst[idx] + " = widget.child('" + lst[idx] + "');";
+ eval(str);
+ var typeName = widget.child(lst[idx]).className();
+
+ if( typeName == "QGroupBox" || typeName == "QButtonGroup" || typeName == "QFrame")
+ {
+ eval("addChildren( widget." + lst[idx] + ");");
+ }
+ }
+}
+