I try to include a script from script
{
Q_OBJECT
public:
Script();
public slots:
void load
(QString file);
//using engine->evaluate(file.tostring) to load js file };
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
};
To copy to clipboard, switch view to plain text mode
main.js
SCRIPT.load('calculator.js'); //class Calculator is define in calculator.js
gg= SCRIPT.loadGUI('calculator.ui');
new Calculator(gg);
gg.show();
SCRIPT.load('calculator.js'); //class Calculator is define in calculator.js
gg= SCRIPT.loadGUI('calculator.ui');
new Calculator(gg);
gg.show();
To copy to clipboard, switch view to plain text mode
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');
gg= SCRIPT.loadGUI('calculator.ui');
SCRIPT.load('calculator.js');
To copy to clipboard, switch view to plain text mode
calculator.js
........
//add this code
new Calculator(gg);
gg.show();
........
//add this code
new Calculator(gg);
gg.show();
To copy to clipboard, switch view to plain text mode
It work very well
Bookmarks