yycking
22nd April 2009, 04:09
I try to include a script from script
class Script: public QObject
{
Q_OBJECT
public:
Script();
public slots:
QWidget* loadGUI(QString file);
void load(QString file); //using engine->evaluate(file.tostring) to load js file
};
main.js
SCRIPT.load('calculator.js'); //class Calculator is define in calculator.js
gg= SCRIPT.loadGUI('calculator.ui');
new Calculator(gg);
gg.show();
But I got the error : Calculator is not defined
If I move some codes from main.js to calculator.ui
main.js
gg= SCRIPT.loadGUI('calculator.ui');
SCRIPT.load('calculator.js');
calculator.js
........
//add this code
new Calculator(gg);
gg.show();
It work very well
class Script: public QObject
{
Q_OBJECT
public:
Script();
public slots:
QWidget* loadGUI(QString file);
void load(QString file); //using engine->evaluate(file.tostring) to load js file
};
main.js
SCRIPT.load('calculator.js'); //class Calculator is define in calculator.js
gg= SCRIPT.loadGUI('calculator.ui');
new Calculator(gg);
gg.show();
But I got the error : Calculator is not defined
If I move some codes from main.js to calculator.ui
main.js
gg= SCRIPT.loadGUI('calculator.ui');
SCRIPT.load('calculator.js');
calculator.js
........
//add this code
new Calculator(gg);
gg.show();
It work very well