I tried the code shown here: http://stackoverflow.com/questions/1...eenshot-qt-qml

On execution I am getting the error written in the title.

My **main.cpp** is:

Qt Code:
  1. #include <QGuiApplication>
  2. #include <QQmlApplicationEngine>
  3. #include <QQuickWindow>
  4. #include <QImage>
  5. #include <QDebug>
  6. #include "screenshot.h"
  7. #include <QQuickView>
  8. #include <QQmlContext>
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. QGuiApplication app(argc, argv);
  13.  
  14. const char* drigUi = "DrigUI";
  15. qmlRegisterType <screenCapture> (drigUi, 1, 0, "ScreenShot");
  16.  
  17. QQmlApplicationEngine engine;
  18. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  19.  
  20. return app.exec();
  21. }
To copy to clipboard, switch view to plain text mode 
I used this **capture** function:

Qt Code:
  1. void screenCapture::capture(QString const &path) const
  2. {
  3. QImage img = currentView_->grabWindow();
  4. img.save(path);
  5. }
To copy to clipboard, switch view to plain text mode 
and added the following in the constructor:

Qt Code:
  1. currentView_ = new QQuickView;
To copy to clipboard, switch view to plain text mode 

My ***main.qml*** :

Qt Code:
  1. import QtQuick 2.4
  2. import QtQuick.Window 2.2
  3.  
  4. import DrigUI 1.0
  5.  
  6. Window
  7. {
  8. visible: true
  9. height: 370
  10. width: 370
  11.  
  12. ScreenShot { id: screenShot }
  13.  
  14. Rectangle
  15. {
  16. id: ll
  17. height: 30
  18. width: 50
  19. x: 180; y: 0; color: "red"
  20. MouseArea
  21. {
  22. anchors.fill: parent
  23. onClicked: screenShot.capture ("l.png")
  24. }
  25. }
  26. }
To copy to clipboard, switch view to plain text mode 

What does that error mean? What is the way to solve it? What else info can I provide here?