问题
I'm using the new version of Blackberry (Blackberry 10) . I'm trying to integrate c++ code with QML , but I faced some problems that I thinks connected to other . in the .h file Q_OBJECT , Q_PROPERTY signals and slots shows that there is syntax error . and in the QML file in which I try to use this type (i.e import CustomTimer 1.0 for example) I got this problem module "CustomTimer" is not installed . how to solve this issue???
回答1:
I'm using QNX Momentics Version 10.1.0
I resolved my errors by right-clicking on my project folder, then selecting Configure -> Add Library...
, and then choose Standard BlackBerry Platform Library. Choose the relevant library to include and click Finish
.
For QObject
, I found it under Platform > Qt Core
回答2:
I corrected the issue in following manner:
- Right Click on your project in Project Explorer.
- Goto Index.
- click Rebuild.
回答3:
For the syntax errors that you are reporting in QNX Momentics for the Q_OBJECT macros and other Qt macros, these errors went away for me after updating to the latest Momentics and SDK release. However, there are still some others who seem to have this issue, and some workarounds have been posted in the Blackberry Developer support forums:
http://supportforums.blackberry.com/t5/Cascades-Development/Beta-4-Momentics-IDE-autocompletion-does-not-work-for-Qt-classes/td-p/2014793
For the error in your QML file, I think you encountering a known limitation with the QML preview for custom components from C++ registered and imported into QML. The QML preview only understands how to display the core Cascades components. This should not affect how your code runs in the simulator or on an actual device.
See:
https://developer.blackberry.com/cascades/download/releasenotes/
under "Known Limitations":
QML preview with C++ objects The QML preview can load and render components based on the Cascades plug-in only (in bb.cascades 1.0). Objects that are registered in C++ in your project are not understood by the QML preview and cannot be loaded and rendered.
In some cases, as a workaround in order to see the preview for the rest of your QML document, you can just comment out the import MyLibrary 1.0
when using the QML preview. However in some cases this could mean commenting out half of your document. For more than very basic QML layouts, and usually after the initial design stage, I have found it more efficient just to build and launch my app to view the actual working QML UI.
回答4:
This worked for me:
I right-clicked my project, and selected in the drop-down menu:
Index > Re-resolve Unresolved Includes
Index > Rebuild
(Using Momentics 2.1.1)
来源:https://stackoverflow.com/questions/13953916/blackberry-10-unresolved-inclusion-qobject