Hi again folks...
I am just giving you an idea of MyWindow class..
/********************MyWindow.h************************/
class MyWindow
: public QObject,
public QScriptable
{
Q_OBJECT
public:
Window();
public slots :
void changeButton();
void clickEvent();
void changeSumthing();
void getexitButton();
private:
signals:
void buttonClicked();
};
/********************MyWindow.h************************/
class MyWindow: public QObject,public QScriptable
{
Q_OBJECT
public:
Window();
public slots :
void changeButton();
void clickEvent();
void changeSumthing();
void getexitButton();
private:
QWidget window;
QPushButton *awakenButton;
QPushButton *exitButton;
signals:
void buttonClicked();
};
To copy to clipboard, switch view to plain text mode
/****************main.cpp********************/
int main(int argc, char **argv)
{
MyWindow *window1=new Window;
QScriptEngine engine;
QScriptValue object = engine.newObject();
object.setProperty("name", QScriptValue(&engine, "Megatron"));
QScriptValue slot = engine.evaluate(file.readAll());
file.close();
//connecting to scriptfile using signal buttonClicked(emitted in clickEvent()slot )
qScriptConnect(window1, SIGNAL(buttonClicked()), object, slot);
return app.exec();
}
/****************main.cpp********************/
int main(int argc, char **argv)
{
QApplication app(argc, argv);
MyWindow *window1=new Window;
QScriptEngine engine;
QScriptValue object = engine.newObject();
object.setProperty("name", QScriptValue(&engine, "Megatron"));
QFile file("window.js");
bool t=file.open(QIODevice::ReadOnly);
QScriptValue slot = engine.evaluate(file.readAll());
QString str=slot.toString();
file.close();
//connecting to scriptfile using signal buttonClicked(emitted in clickEvent()slot )
qScriptConnect(window1, SIGNAL(buttonClicked()), object, slot);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Lastly my window.js file is:
/*********window.js************/
return function() {
var sender = __qt_sender__;
sender.value=1;
sender.changeButton();
//tried connecting the exitButton click signal to the slot changeSumthing..but not working
sender.exitButton.clicked.connect(sender,"changeSumthing");
//Also can we initialize objects here..and then access the methods
var obj2=new MyWindow;
}
/*********window.js************/
return function() {
var sender = __qt_sender__;
sender.value=1;
sender.changeButton();
//tried connecting the exitButton click signal to the slot changeSumthing..but not working
sender.exitButton.clicked.connect(sender,"changeSumthing");
//Also can we initialize objects here..and then access the methods
var obj2=new MyWindow;
}
To copy to clipboard, switch view to plain text mode
I hope this will help u to understand my problem better..
Bookmarks