Results 1 to 10 of 10

Thread: Problems with QtQuick wizard generated project

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2014
    Posts
    14
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Problems with QtQuick wizard generated project

    Hello,

    I'm trying to add a C++ defined type to a simple QML file, but when I start debugging the application I receive the following error: "module "APP_CHILD" is not installed
    import APP_CHILD 1.0".

    The application I'm running is derived from a wizard generated QtQuick application which is meant to handle native system events some way.

    The program is structured as follows:

    qtquick2applicationviewer/qtquick2applicationviewer.cpp (Wizard generated)
    qtquick2applicationviewer/qtquick2applicationviewer.h (Wizard generated)
    qtquick2applicationviewer/qtquick2applicationviewer.pri (Wizard generated)
    qml/provaintegrazione/main.qml
    app.cpp
    app.h
    main.cpp
    provaintegrazione.pro
    provaintegrazione.pro.user
    and this is the code of the files I modified by myself:

    app.h

    Qt Code:
    1. #ifndef APP_H
    2. #define APP_H
    3.  
    4. #include <QTimer>
    5. #include "qtquick2applicationviewer.h"
    6.  
    7. class cAppChild : public QObject
    8. {
    9. Q_OBJECT
    10.  
    11. QTimer timer;
    12. bool check;
    13.  
    14. public:
    15. cAppChild();
    16. virtual ~cAppChild(){}
    17.  
    18. private slots:
    19. void change(){ check = !check; timer.start(); }
    20. };
    21.  
    22. class cApp : public QtQuick2ApplicationViewer
    23. {
    24. Q_OBJECT
    25.  
    26. bool nativeEvent(const QByteArray &eventType, void *message, long *result);
    27.  
    28. public:
    29. explicit cApp(QWindow *parent = 0);
    30. virtual ~cApp();
    31. };
    32.  
    33. #endif // APP_H
    To copy to clipboard, switch view to plain text mode 


    app.cpp

    Qt Code:
    1. #include <QtDeclarative>
    2. #include "app.h"
    3.  
    4. cAppChild::cAppChild()
    5. {
    6. check = false;
    7. timer.start();
    8. //Connections for attach/detach notification
    9. connect(&timer, SIGNAL(timeout()), this, SLOT(change()));
    10. }
    11.  
    12.  
    13.  
    14. cApp::cApp(QWindow *parent) : QtQuick2ApplicationViewer(parent)
    15. {
    16. }
    17.  
    18. cApp::~cApp()
    19. {
    20. }
    21.  
    22. bool cApp::nativeEvent(const QByteArray &eventType, void *message, long *result)
    23. {
    24. if( eventType == "windows_generic_MSG" )
    25. {
    26. // Some kind of event handling.
    27. }
    28. return false;
    29. }
    To copy to clipboard, switch view to plain text mode 


    main.cpp

    Qt Code:
    1. #include <QtGui/QGuiApplication>
    2. #include <QtDeclarative>
    3. #include "app.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QGuiApplication app(argc, argv);
    8.  
    9. qmlRegisterType<cAppChild>("APP_CHILD", 1, 0, "appchild");
    10.  
    11. cAppChild myApp;
    12.  
    13. cApp viewer;
    14. viewer.setMainQmlFile(QStringLiteral("qml/provaintegrazione/main.qml"));
    15. viewer.showExpanded();
    16.  
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

    qml/provaintegrazione/main.qml

    Qt Code:
    1. import QtQuick 2.0
    2. import QtQuick.Controls 1.0
    3. import APP_CHILD 1.0
    4.  
    5. ApplicationWindow
    6. {
    7. id: main_window
    8. Rectangle
    9. {
    10. id: pippo
    11. width: 360
    12. height: 360
    13. color: "red"
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 


    Can anybody try to use the code above on his QtCreator and explain me how to make the qml code recognize the APP_CHILD module?
    Last edited by anda_skoa; 16th March 2014 at 11:56. Reason: changed [qtclass] to [code]

Similar Threads

  1. How to create a QtQuick 1 Application project?
    By TheIndependentAquarius in forum Qt Tools
    Replies: 1
    Last Post: 23rd October 2013, 11:02
  2. MSVC Project generated using qmake - turn off flat structure
    By Piskvorkar in forum Qt Programming
    Replies: 3
    Last Post: 4th February 2013, 23:25
  3. Replies: 1
    Last Post: 29th September 2011, 11:14
  4. visualize qtQuick project
    By amadanes in forum Newbie
    Replies: 1
    Last Post: 8th May 2011, 23:15
  5. Qt Creator Crossplatform project wizard
    By lunarcloud in forum Qt Tools
    Replies: 0
    Last Post: 11th April 2011, 07:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.