I am trying to pass an instance of Application class, which is derived from QGuiApplication, to QML and access its properties there. For the reasons I don't understand it tells the property is undefined: "Unable to assign [undefined] to QString". At the same time properties inherited from QGuiApplication can be accessed without any problem, e.g. app.applicationName works fine.

Here is the QML code (main.qml). The Text component was supposed to show the application version.
Qt Code:
  1. import QtQuick 2.7
  2. import QtQuick.Controls 2.0
  3.  
  4. ApplicationWindow
  5. {
  6. title: "another title"
  7. visible: true
  8. width: 1000
  9. height: 800
  10.  
  11. Rectangle
  12. {
  13. color: "lightsteelblue"
  14. anchors.fill: parent
  15.  
  16. Text
  17. {
  18. anchors.centerIn: parent
  19. //text: app.updatesAvailable ? "Updates Are Available" : "My Application"
  20. //text: app.updatesAvailable
  21. text: app.versionString
  22. //text: app.applicationName
  23. //text: testObj.title
  24. }
  25. } // Rectangle
  26. } // ApplicationWindow
To copy to clipboard, switch view to plain text mode 

This is how the application instance is passed to QML (main.cpp):
Qt Code:
  1. #include "application.h"
  2. #include <QQmlContext>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. Application app(argc, argv);
  7.  
  8. QQmlApplicationEngine engine;
  9. engine.rootContext()->setContextProperty("app", &app);
  10. engine.load(QUrl("qrc:///qml/main.qml"));
  11.  
  12. return app.start();
  13. }
To copy to clipboard, switch view to plain text mode 

And, finally, the Application class declaration (application.h) looks like this:
Qt Code:
  1. #ifndef APPLICATION_H
  2. #define APPLICATION_H
  3.  
  4. #include <QGuiApplication>
  5.  
  6. class Application: public QGuiApplication
  7. {
  8. Q_PROPERTY(bool updatesAvailable READ checkForUpdates)
  9. Q_PROPERTY(QString versionString READ getVersionString CONSTANT)
  10.  
  11. public:
  12. Application(int &argc, char **argv);
  13. ~Application();
  14.  
  15. bool isRunning() const { return false; }
  16. bool checkForUpdates() { return true; }
  17.  
  18. QString getVersionString() const { return "2.7"; }
  19.  
  20. int start();
  21. }; // Application
  22.  
  23. #endif // APPLICATION_H
To copy to clipboard, switch view to plain text mode 

Any clues?