Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Custom QML module problem
Forum Updated to NodeBB v4.3 + New Features

Custom QML module problem

Scheduled Pinned Locked Moved Mobile and Embedded
11 Posts 5 Posters 10.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mlong
    wrote on last edited by
    #2

    Are you registering XXXX with your QDeclarativeContext the same way in both projects?

    Software Engineer
    My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      horxpig
      wrote on last edited by
      #3

      [quote author="mlong" date="1332358065"]Are you registering XXXX with your QDeclarativeContext the same way in both projects?
      [/quote]

      Yes, in both projects I'm using:

      qmlRegisterType<XXXX>("XXXX", 1, 0, "XXXX");

      exactly in the same way, qml does recognize the module when i'm typing the code, but when i try to build it, it says it's not installed :(

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #4

        You also want to make sure that you register your type before you set the QML source file. I've been caught by that one before.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          horxpig
          wrote on last edited by
          #5

          [quote author="mlong" date="1332364312"]You also want to make sure that you register your type before you set the QML source file. I've been caught by that one before.[/quote]

          It is registered before, I think the problem might be more on the QML side, but I'm out of ideas :(

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mlong
            wrote on last edited by
            #6

            Without seeing code, I don't think there's a lot anyone can do. Can you create a small sample snippet which contains the pertinent sections of code from where you do your registration in both the test and production code? The key will lie someone where in the differences between the apps.

            Software Engineer
            My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              task_struct
              wrote on last edited by
              #7

              Hello,

              you can save/add contacts from QML. See "this thread":http://qt-project.org/forums/viewthread/14628/ for example.

              "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

              • Linu...
              1 Reply Last reply
              0
              • H Offline
                H Offline
                horxpig
                wrote on last edited by
                #8

                [quote author="task_struct" date="1332401107"]Hello,

                you can save/add contacts from QML. See "this thread":http://qt-project.org/forums/viewthread/14628/ for example.[/quote]

                That doesn't work on meego for some reason, it just creates a blank contact but it doesn't add the information to it, that's why I'm doing it on a C++ class. thanks anyway :)

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  horxpig
                  wrote on last edited by
                  #9

                  My code is basically something like this in both apps:

                  (ContactCreator is my XXXX class)

                  In my ContactCreator.h:
                  @
                  #ifndef CONTACTCREATOR_H
                  #define CONTACTCREATOR_H

                  #include <QObject>
                  class ContactCreator : public QObject
                  {
                  Q_OBJECT
                  public:
                  Q_INVOKABLE bool contacto(QString nombre,QString email);
                  explicit ContactCreator(QObject *parent = 0);

                  };#endif // CONTACTCREATOR_H
                  @

                  ContacCreator.cpp
                  @
                  #include "contactcreator.h"
                  #include <QContactManager>
                  #include <QContactName>
                  using namespace QtMobility;
                  QTM_USE_NAMESPACE

                  ContactCreator::ContactCreator(QObject *parent) : QObject(parent){}

                  bool ContactCreator::contacto(QString nombre, QString correo){
                  QContactManager *cm = new QContactManager();
                  QContact example;
                  QContactName nomi;
                  nomi.setFirstName(correo);
                  nomi.setLastName(nombre);
                  example.saveDetail(&nomi);
                  bool resp;
                  if(cm->saveContact(&example)){
                  resp = true;
                  }else{
                  resp = false;
                  }
                  return resp;
                  }
                  @

                  In my Pro file i added:
                  @
                  symbian::TARGET.CAPABILITY =
                  ReadUserData
                  ReadDeviceData
                  ReadUserData
                  WriteUserData

                  CONFIG += mobility
                  MOBILITY += contacts

                  SOURCES +=
                  contactcreator.cpp

                  HEADERS +=
                  contactcreator.h
                  @

                  And finally in the qmlapplicationviewer.cpp i modified the following:
                  @

                  // Enable debugging before any QDeclarativeEngine is created
                  struct QmlJsDebuggingEnabler
                  {
                  QmlJsDebuggingEnabler()
                  {
                  QDeclarativeDebugHelper::enableDebugging();
                  }
                  };
                  @
                  To be like this:
                  @
                  #include "../contactcreator.h"
                  // Enable debugging before any QDeclarativeEngine is created
                  struct QmlJsDebuggingEnabler
                  {
                  QmlJsDebuggingEnabler()
                  {
                  QDeclarativeDebugHelper::enableDebugging();
                  qmlRegisterType<ContactCreator>("ContactCreator", 1, 0, "ContactCreator");
                  }
                  };
                  @

                  So now in my QML I call:
                  @
                  import ContactCreator 1.0

                  [...Some qml code...]
                  ContactCreator{
                  id: contCreator
                  Component.onCompleted:{
                  contCreator.contacto("TestLastName","TestName");
                  }
                  }
                  @

                  I did it exactly the same in both apps and it only fails in one of them :/

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SanyStation
                    wrote on last edited by
                    #10

                    [quote author="mlong" date="1332364312"]You also want to make sure that you register your type before you set the QML source file. I've been caught by that one before.[/quote]

                    Thanks. You helped me a lot.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Scorp1us
                      wrote on last edited by
                      #11

                      I am trying to port a 4.7 class to 5.x, and I'm having this problem. However, its not a visual component, It is a QAbstractItemModel derived component. What is the resolution for that?

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved