Results 1 to 2 of 2

Thread: Cannot assign to non-existent default property

  1. #1
    Join Date
    Aug 2012
    Posts
    30
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot assign to non-existent default property

    Hi, guys I am trying to add qml types. Here is my example.qml:

    Qt Code:
    1. import InsideDial 1.0
    2.  
    3. import QtQuick 1.1
    4.  
    5. InsideDial {
    6.  
    7. value: 12
    8.  
    9. Image{
    10. x: -19; y: -201
    11. source: "svg/Background(Fblack).svg"
    12. }
    13. Image{
    14. id: needle
    15. x: 184; y: -80
    16. smooth: true
    17. source: "svg/Needle(w).svg"
    18. transform: Rotation {
    19. id: needleRotation
    20. origin.x: 6; origin.y: 100
    21. angle: calculateAngle(value)
    22. }
    23. }
    24. function calculateAngle(value){
    25. var angle = 0;
    26. if(value >= 0)
    27. angle = Math.min(Math.max(0, root.value*2.6 - 100), 90);
    28. else
    29. angle = Math.min(Math.max(-90, root.value*2.6 + 100), 0);
    30. return angle;
    31. }
    32.  
    33. }
    To copy to clipboard, switch view to plain text mode 

    And here is my main.cpp:

    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QDeclarativeEngine>
    3. #include <QDeclarativeComponent>
    4. #include <QDebug>
    5. #include "InsideDial.h"
    6.  
    7. int main(int argc, char ** argv)
    8. {
    9. QCoreApplication app(argc, argv);
    10. qmlRegisterType<InsideDial>("InsideDial", 1,0, "InsideDial");
    11.  
    12. QDeclarativeEngine engine;
    13. QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
    14. InsideDial *dial = qobject_cast<InsideDial *>(component.create());
    15. if (dial) {
    16.  
    17. qWarning() << "The dial " << dial->value() << " valued";
    18. } else {
    19. qWarning() << component.errors();
    20. }
    21. qDebug() << component.errors();
    22. return 0;
    23.  
    24. }
    To copy to clipboard, switch view to plain text mode 

    When I run my project I get this error :

    QDeclarativeComponent: Component is not ready
    (qrc:example.qml:9:5: Cannot assign to non-existent default property)
    All of my .svg files are added to my .qrc file but I don't know how to fix this. Could you please help me?


    Added after 1 20 minutes:


    I have also tried this in my main.cpp:

    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QDeclarativeEngine>
    3. #include <QDeclarativeComponent>
    4. #include <QDebug>
    5. #include "InsideDial.h"
    6.  
    7. int main(int argc, char ** argv)
    8. {
    9. QCoreApplication app(argc, argv);
    10. qmlRegisterType<InsideDial>("InsideDial", 1,0, "InsideDial");
    11.  
    12. QDeclarativeEngine engine;
    13. QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
    14. QObject *o;
    15. while(!component.isReady())
    16. o = component.create();
    17. InsideDial *dial = qobject_cast<InsideDial *>(o);
    18. if (dial) {
    19.  
    20. qWarning() << "The dial " << dial->value() << " valued";
    21. } else {
    22. qWarning() << component.errors();
    23. }
    24. qDebug() << component.errors();
    25. return 0;
    26.  
    27. }
    To copy to clipboard, switch view to plain text mode 

    But this does not work too..
    Last edited by jeff28; 3rd September 2012 at 09:27.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cannot assign to non-existent default property

    What does your InsideDial class look like?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 0
    Last Post: 20th February 2012, 12:52
  2. how can we assign value in unsigned char[]
    By gauravg in forum General Programming
    Replies: 1
    Last Post: 13th April 2011, 08:44
  3. How to Assign a Variable into LineEdit
    By mcht_z in forum Newbie
    Replies: 2
    Last Post: 18th February 2011, 19:55
  4. QFileDialog 'Save As' to non-existent directory
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 9th September 2010, 22:32
  5. boost::assign
    By Sivert in forum General Programming
    Replies: 0
    Last Post: 2nd May 2007, 00:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.