After a lot of messing about I finally got this to compile (after some edits) http://developer.nokia.com/Community...eenShot_Qt/QML

It's all implemented, the command screenObject highlights blue like it should, but when I try use the function I get "ReferenceError: Can't find variable: screenObject"

ScreenClass.cpp

Code:
#include "ScreenClass.h"
#include <QtCore/QDateTime>

ScreenClass::ScreenClass(QmlApplicationViewer *currentView){
    this->currentView = currentView;
}

void ScreenClass::capture(){

    QPixmap::grabWidget(currentView).save("E:/Images/" + QDateTime::currentDateTime().toString("d-M-yy_h-m-s") + ".png");
    //QPixmap::grabWidget(currentView).save( QDir::currentPath() + "/screenShot/" + FILE_NAME+ ".png");
}
ScreenClass.h

Code:
#ifndef SCRENCLASS_H
#define SCRENCLASS_H

#include <QDebug>
#include <QPixmap>
#include <qmlapplicationviewer.h>
#include <QDir>

class ScreenClass : public QObject
{

public:
    ScreenClass(QmlApplicationViewer* currentView);

    Q_OBJECT public: Q_INVOKABLE void capture();

private:
    QmlApplicationViewer* currentView;
};

#endif // SCRENCLASS_H
then
Code:
  QmlApplicationViewer viewer;
        ScreenClass screenClass(&viewer);
        viewer.rootContext()->setContextProperty("screenObject", &screenClass);
in the main.cpp

Anyone know how to solve this ?