×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    17

    Extending QML - Adding Types Example

    Hi everyone!
    I have just writen my own class in c++ and added it as a type to use with QML - just like in example in topic.
    All seems to be ok except nothing is working
    I get an error:
    Code:
    QDeclarativeComponent: Component is not ready
    (qrc:mySysInfo.qml: File not found)
    Path to mySysInfo.qml is in resource editor set to:
    Code:
     <!DOCTYPE RCC><RCC version="1.0">
     <qresource>
         <file>qml/QtQuick2/mySysInfo.qml</file>
     </qresource>
     </RCC>
    Remark: mySysInfo.qml is not a main project file but I want to use it as a component in main,qml.
    What am I doing wrong?

    The second question is I included into mySysInfo.h headers <QSystemInfo> and <QSystemDeviceInfo>, CONFIG += mobility
    MOBILITY += systeminfo in application .pro file but when I try to write something like this
    Code:
     QSystemDeviceInfo *si;
        si =  new QSystemDeviceInfo(this);
    I get build error
    Code:
    E:\SYMBIAN\moje\QtQuick2-build-simulator\..\QtQuick2\mySysInfo.cpp:8: błąd:'QSystemDeviceInfo' was not declared in this scope
    Why?

  2. #2
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Extending QML - Adding Types Example

    Hi,

    1. The component's filename must always start with a capital letter.
    2. Have you forgotten to add #include <QSystemDeviceInfo>?

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    17

    Re: Extending QML - Adding Types Example

    ad.1 - I change it tomorrow and try again
    ad.2 - no. it is included

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    17

    Re: Extending QML - Adding Types Example

    Ok, I have changed all file names to beginn with capitals, my library name too but nothing is changed. I have the same errors.
    I think the purpose of errors is that my component is being made dynamicly and the main interface (main.qml) is done by qmlaplicationviewer. But how to solve this conflict if it really is a conflict.
    Ok, I solved it - it is not allowed to mix two different types of view: standard (by viewer) and declarative view.
    My component works great except that it shows undefined values because I slill can not use QSystemDeviceInfo etc.
    Here is my .pro file:
    Code:
    folder_01.source = qml/QtQuick2
    folder_01.target = qml
    DEPLOYMENTFOLDERS = folder_01
    
    Qt += declarative
    
    # Additional import path used to resolve QML modules in Creator's code model
    QML_IMPORT_PATH =
    
    symbian:TARGET.UID3 = 0xE26A57B0
    
    SOURCES += main.cpp \
        mySysInfo.cpp
    
    CONFIG += mobility
    MOBILITY += systeminfo
    
    
    include(qmlapplicationviewer/qmlapplicationviewer.pri)
    qtcAddDeployment()
    
    HEADERS += \
        mySysInfo.h
    
    RESOURCES += \
        MySysInfo.qrc
    Best regards, Andrzej.
    Last edited by akrynski; 2011-05-19 at 09:15.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    17

    Re: Extending QML - Adding Types Example

    I hate replying to myself but someone can find it helpfull
    So I found my foult - wrong location of QTM_USE_NAMESPACE clausule.
    But I still get undefined values from my component, perhaps from QSystemDeviceInfo class.
    Let you see my code:
    Code:
    #include "mySysInfo.h"
    #include <QSystemInfo>
    #include <QSystemDeviceInfo>
    #include <QDebug>
    mySystemInfo::mySystemInfo(QObject *parent)
    : QObject(parent)
    {
    
        QSystemDeviceInfo* si;
        si =  new QSystemDeviceInfo(this);
        this->setManufacturer(QString(si->manufacturer()));
        qWarning() << "Manufacturer name is" << si->manufacturer();
        this->setProductName(si->productName());
        this->setModel(si->model());
    
        delete si;
    ...
    ...
    QString mySystemInfo::manufacturer() const
    {
        return m_manufacturer;
    }
    ....
    ...
    and from main.qml:
    Code:
    ...
    ...
     Text {
            id: info
    
            text: "manufacturer = " + MySysInfo.manufacturer
    ...
    ...
    By the way: I can't see any reply from qWarning so I can not check what happens.

    CAN ANYBODY HELP ME? Now I really don't know what to do

  6. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    17

    Thumbs up [SOLVED]Re: Extending QML - Adding Types Example

    PROBLEM SOLVED by myself.

Similar Threads

  1. How to call/load another QML file from QML ?
    By cadlg in forum [Archived] Qt Quick
    Replies: 5
    Last Post: 2011-07-28, 09:15
  2. [Qt QML] Questions regarding QML Performance
    By SeanZhang in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-05-05, 13:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×