This works fine for me:
#include <QApplication>
#include <QScriptEngine>
#include <QtDebug>
Q_OBJECT
public:
public slots:
void drawr() { qDebug() << Q_FUNC_INFO; }
};
#include "main.moc"
int main(int argc, char **argv) {
QScriptEngine engine;
RItem item;
QScriptValue val = engine.newQObject(&item);
engine.globalObject().setProperty("rectangle", val);
engine.evaluate("rectangle.drawr()") ;
return 0;
}
#include <QApplication>
#include <QScriptEngine>
#include <QtDebug>
class RItem : public QObject {
Q_OBJECT
public:
RItem() : QObject() {}
public slots:
void drawr() { qDebug() << Q_FUNC_INFO; }
};
#include "main.moc"
int main(int argc, char **argv) {
QApplication app(argc, argv);
QScriptEngine engine;
RItem item;
QScriptValue val = engine.newQObject(&item);
engine.globalObject().setProperty("rectangle", val);
engine.evaluate("rectangle.drawr()") ;
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks