Hi,
I want to use QtScript in one of my application. for this I have created following class.
datefunction.h
#ifndef DATEFUNCTION_H
#define DATEFUNCTION_H
#include <QtCore>
class DateFunction
: public QObject{
Q_OBJECT
public:
explicit DateFunction
(QObject *parent
= 0);
signals:
public slots:
};
#endif // DATEFUNCTION_H
#ifndef DATEFUNCTION_H
#define DATEFUNCTION_H
#include <QtCore>
class DateFunction : public QObject
{
Q_OBJECT
public:
explicit DateFunction(QObject *parent = 0);
signals:
public slots:
int daysInYear(QString year);
};
#endif // DATEFUNCTION_H
To copy to clipboard, switch view to plain text mode
datefunction.cpp
#include "datefunction.h"
DateFunction
::DateFunction(QObject *parent
) :{
}
int DateFunction
::daysInYear(QString year
) {
int str=0;
if (!d1.isValid())
return str;
str = d1.daysInYear();
return str;
}
#include "datefunction.h"
DateFunction::DateFunction(QObject *parent) :
QObject(parent)
{
}
int DateFunction::daysInYear(QString year)
{
int str=0;
QDate d1 = QDate::fromString(year,"yyyy");
if (!d1.isValid())
return str;
str = d1.daysInYear();
return str;
}
To copy to clipboard, switch view to plain text mode
Now I want user to use this in qtscript and user should be able to call daysInYear() method in QScriptEngine.evaluate() function by passing this method and required parameter as a string.
Can anybody help me on this.
Regards
Manish
Bookmarks