Trolltech Home | QSA-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

QSA-interest Archive, October 2005
adding functions to the Application-Object


Message 1 in thread

Hi
It´s me again ;) 
I would like to have a possibility to add functions to the Application-Object.
It is usefull for me to have functions like 
	"Application.Project( id )" 
	"Application.Data( id )"
	"Application.View( id )"
instead of 
	"Application.Project1"
	"Application.Project2"
	etc.
	"Application.Data1"
	"Application.Data2"
	etc.
	"Application.View1"
	"Application.View2"
	etc.
Is that possible with QSA 1.2.0 ?

	Greetings 
		Jens


Message 2 in thread

Jens wrote:

 > Hi
 > It´s me again ;) I would like to have a possibility to add functions 
to the Application-Object.
 > It is usefull for me to have functions like     "Application.Project( 
id )"     "Application.Data( id )"
 >     "Application.View( id )"
 > instead of     "Application.Project1"
 >     "Application.Project2"
 >     etc.
 >     "Application.Data1"
 >     "Application.Data2"
 >     etc.
 >     "Application.View1"
 >     "Application.View2"
 >     etc.
 > Is that possible with QSA 1.2.0 ?
 >
 >     Greetings         Jens


Hi Jens,

It is possible to extend any object with functions on the fly. In 
combination with the [] accessor you can implement these functions like 
this:

Application.Project = function(a) { return Application["Project" + a]; }
Application.Data= function(a) { return Application["Data"+ a]; }
Application.View= function(a) { return Application["View" + a]; }

Best regards,
Gunnar