Custom QML module problem
-
[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 :(
-
[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 :(
-
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.
-
Hello,
you can save/add contacts from QML. See "this thread":http://qt-project.org/forums/viewthread/14628/ for example.
-
[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 :)
-
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_NAMESPACEContactCreator::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
WriteUserDataCONFIG += mobility
MOBILITY += contactsSOURCES +=
contactcreator.cppHEADERS +=
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 :/
-
[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.