10-22-2013 05:36 AM
In my class lib, class A uses enums defined in class B. When I use A in qml, do I have to call qmlRegisterType for B in applicaiton class? Can I call qmlRegisterType for B in A, like in A's constructor?
10-22-2013 05:40 AM
10-22-2013 05:44 AM
I called qmlRegisterType for A in application class. But, some of A's properties are enums defined in B. When I tried to set them in QML, I can't see any setter calls in debug mode. But, in my Library, the user uses either A or B. they never need to use both, as A is a kind of wrapper for B. I don't want to redefined those enums in A. Otherwise, I need to write extra conversion code. So, I wonder if I can qmlRegisterType B some where else, such as in A.
10-22-2013 05:47 AM
10-22-2013 05:48 AM
10-22-2013 06:15 AM
I don't see why not.
If you want to understand what exactly is happening when you do a qmlRegisterType I suggest you take a look at this...
However I think you are overcomplicating things, if all you want to do is use the enums in your QML, registering the class and its enums within your applicationui.cpp before the qml instantiation should be all you need to do. It doesn't matter then whether you are using it to pass a value to another class or not.
I do this in my apps that way the type is available to all classes.
10-22-2013 06:26 AM
I am creating a static class library for others to use. I don't want the user to do a lot of things to use this lib, such as calling qmlRegisterType for a lot of public classes.
10-22-2013 06:31 AM - edited 10-22-2013 06:34 AM
Ok understood, at this point then could you post a simple example of the code you have so far?
As long as the class constructor is called before the enum is used in the QML then I see no reason for it not to work so we will need to look at your code.
[Edit] Alternatively do all your registering in a single function and inform your developers the call needs to be made before the QML is created.
10-22-2013 06:31 AM