This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Javascript and forms

Tags: None
(comma "," separated)
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS

Javascript and forms

Tue Mar 03, 2009 2:56 pm
Anyone knows a tutorial of how to make forms in javascript. I wanted to make a configuration form for my script but don't know how to use the *. ui files.

Thanks in advance.


Ignacio Serantes, proud to be a member of KDE forums since 2008-Nov.
trippinnik
Registered Member
Posts
12
Karma
0

Re: Javascript and forms

Fri Mar 27, 2009 4:23 am
I've just started looking into this as well, so someone else may know better than me .. but here's an example of what I found using a ui file I created in designer

guiLoader = new QUiLoader( this );
ui = new QFile (Amarok.Info.scriptPath()+"/settings.ui" );
ui.open( QIODevice.ReadOnly );
var configWindow = guiLoader.load( ui, this );
ui.close();

If you want to hand code it you can do something like:

var someVariable = new QWidget();

There's a bunch of info here Also I've been reading though other people's scripts to see what they've done.
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS

Re: Javascript and forms

Fri Mar 27, 2009 9:00 am
Thank you so much. Without a designer construct forms is very hard.

Update: I try your code and kills my Amarok.

Last edited by Ignacio Serantes on Fri Mar 27, 2009 2:14 pm, edited 1 time in total.


Ignacio Serantes, proud to be a member of KDE forums since 2008-Nov.
browner
Registered Member
Posts
1
Karma
0

Re: Javascript and forms

Mon Apr 27, 2009 8:49 pm
Hi, wondering if someone can help me.

Say, in the quoted example below, settings.ui represents a simple window with one QPushButton() object in the middle named "pushButton". (created using Qt Designer).

If I add the line

Code: Select all
    configWindow.show()



to my script then the gui pops onto the screen and I can see the window and push button as expected.

Now I wish to bind a function to the clicked signal of the push button so I can assign it some functionality.

I can do this as follows:

Code: Select all
    configWindow.children()[0].clicked.connect( someFunction );



My question is, how can I do this using the objects NAME (ie. pushButton) rather than the number 0 (first child object of configWindow?). As when building complex interfaces this obviously quickly gets out of hand and names become the most sensible way to do it.

Sadly the following code fails miserably (Type Error - not an object).

Code: Select all
    configWindow.pushButton.clicked.connect( someFunction );



The answer is somewhere on this page http://doc.trolltech.com/4.4/script-calculator.html but I cant figure it out. :(

Can someone help me out?

Thanks.

Chris

trippinnik wrote:I've just started looking into this as well, so someone else may know better than me .. but here's an example of what I found using a ui file I created in designer

guiLoader = new QUiLoader( this );
ui = new QFile (Amarok.Info.scriptPath()+"/settings.ui" );
ui.open( QIODevice.ReadOnly );
var configWindow = guiLoader.load( ui, this );
ui.close();

If you want to hand code it you can do something like:

var someVariable = new QWidget();

There's a bunch of info here Also I've been reading though other people's scripts to see what they've done.


Bookmarks



Who is online

Registered users: Bing [Bot], gfielding, Google [Bot], markhm, Sogou [Bot], Yahoo [Bot]