class CALCSHARED_EXPORT Calc : public QObject{ Q_OBJECT public: Calc(QObject* pwgt) : QObject(pwgt){ qDebug() << "[DLL]::CREATE"; QScriptEngine *sh_engine = new QScriptEngine(this); qDebug() << "the magic number is:" << sh_engine->evaluate("1 + 2").toNumber(); }};
QScriptEngine *sh_engine = new QScriptEngine(this);qDebug() << "the magic number is:" << sh_engine->evaluate("1 + 2").toNumber();Calc *s_calc = new Calc(this);
C++ (Qt)qDebug() << qApp;
#ifndef CALC_H#define CALC_H#include "calc_global.h"#include <QObject>//#include <QScriptEngine>//#include <qDebug>//class CALCSHARED_EXPORT Calc//{// public:// Calc();//};class CALCSHARED_EXPORT Calc : public QObject { Q_OBJECT public: Calc(QObject *parent = 0);};#endif // CALC_H
#ifndef CALC_GLOBAL_H#define CALC_GLOBAL_H#include <QtCore/qglobal.h>#if defined(CALC_LIBRARY)# define CALCSHARED_EXPORT Q_DECL_EXPORT#else# define CALCSHARED_EXPORT Q_DECL_IMPORT#endif#endif // CALC_GLOBAL_H
#include "calc.h"#include <QScriptEngine>#include <qDebug>Calc::Calc(QObject *parent) : QObject(parent){ QScriptEngine *ml = new QScriptEngine(this); qDebug() << ml->evaluate("1+2+5").toNumber();}
void MainWindow::on_pushButton_3_clicked(){ Calc *mc = new Calc(this);}
void MainWindow::on_pushButton_3_clicked(){ qDebug() << "this: " << this; Calc *mc = new Calc(this);}
#ifndef CALC_H#define CALC_H#include "calc_global.h"#include <QObject>class CALCSHARED_EXPORT Calc : public QObject { Q_OBJECT public: Calc(QObject *parent = 0);};#endif // CALC_H
#include "calc.h"#include <QScriptEngine>#include <qDebug>Calc::Calc(QObject *parent) : QObject(parent){ qDebug() << "parent: " << parent; qDebug() << "this: " << this; QScriptEngine *ml = new QScriptEngine(this); qDebug() << ml->evaluate("1+2+5").toNumber();}