Hi,

I want to use QtScript in one of my application. for this I have created following class.


datefunction.h

Qt Code:
  1. #ifndef DATEFUNCTION_H
  2. #define DATEFUNCTION_H
  3.  
  4. #include <QtCore>
  5.  
  6. class DateFunction : public QObject
  7. {
  8. Q_OBJECT
  9.  
  10. public:
  11. explicit DateFunction(QObject *parent = 0);
  12.  
  13. signals:
  14.  
  15. public slots:
  16. int daysInYear(QString year);
  17. };
  18.  
  19. #endif // DATEFUNCTION_H
To copy to clipboard, switch view to plain text mode 


datefunction.cpp

Qt Code:
  1. #include "datefunction.h"
  2.  
  3. DateFunction::DateFunction(QObject *parent) :
  4. QObject(parent)
  5. {
  6. }
  7.  
  8. int DateFunction::daysInYear(QString year)
  9. {
  10. int str=0;
  11. QDate d1 = QDate::fromString(year,"yyyy");
  12. if (!d1.isValid())
  13. return str;
  14. str = d1.daysInYear();
  15. return str;
  16. }
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