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

QSA-interest Archive, October 2005
overloaded functions


Message 1 in thread

Hi
I´m still working on a solution for the problem I described in the mail 
"automatic casting of variables to its superclass-type". 
I thought about introducing a function "cast()" in each wrapper-object which 
casts to the superclass:
class MyClass : public MySuperClass
{
        public slots:
                void wrapFunc1();
                void wrapFunc2();
                MySuperClass* cast() { return this; }
}
This works fine as long as MySuperClass has no superclass itself. But if 
MySuperClass looks like this I get problems:
class MySuperClass : public MySuperSuperClass
{
        public slots:
                virtual void wrapSuperFunc1();
                virtual void wrapSuperFunc2();
		MySuperSuperClass* cast() {return this;}
}

If I try to write a script which casts a MyClass to a MySuperSuperClass I can 
see two functions in the popup combobox in QSA Workbench:
1) function  cast() : MySuperSuperClass
2) function  cast() : MySuperClass

Script:
var s = new MySuperClass();
var c = new MyUseClass();
c.setMyClass( s.cast() );

If I choose function 1 I get the error:
Error. No matching slot found, available overloads are
    void setMyClass(MySuperSuperClass* superClass)

Does anybody has any idea how it would be possible to overload functions in 
QSA ? The combobox recognises two functions with different return-types but 
the interpreter somehow stops checking for a working function after it has 
failed with the first found function.

	Greetings
		Jens


--------------------
class MyUseClass
{
        public slots:
                void setMyClass(MySuperSuperClass* superClass);
}


Message 2 in thread

Jens wrote:

> Does anybody has any idea how it would be possible to overload functions in 
> QSA ? The combobox recognises two functions with different return-types but 
> the interpreter somehow stops checking for a working function after it has 
> failed with the first found function.

Hi Jens,

Overloaded functions is not possible without some work in the engine. 
This version of QSA was not designed to ever handle it ;-( In the next 
major version we will try to fit function overloading into the engine.

Best regards,
Gunnar