码迷,mamicode.com
首页 > 其他好文 > 详细

How To Add QML Module with Plugins for Qt Creator

时间:2014-10-30 10:27:42      阅读:362      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   color   ar   for   sp   on   art   

I decided to take a plunge into a KDE Plasma development with a simple plasmoid with Qt Creator. There’s a very good overview and a guide

However, you will notice that when you do this in Qt Creator

import org.kde.plasma.core 0.1 as PlasmaCore

you will get an underline and the following error

QML module not found

followed by import paths and some vague tip about QML_IMPORT_PATH and importPaths property. What this means is that you need to explicitly declare the import path for KDE components in your *.qmlproject file. Specifically, directly in/under the Project container add the following property

importPaths: [ "/usr/lib64/kde4/imports" ]

or whatever the case is for your specific environment. Now switching back to your .qml file you will notice that the red underline is still there but the message is different when you hover over it

QML module does not contain information contained in plugins

First, the QML can be run at this point. Second, this is because KDE has not included plugins.qmltypes files with their Plasma components. To generate them yourself you can run a command

qmlplugindump org.kde.plasma.core 0.1 /usr/lib64/kde4/imports > /usr/lib64/kde4/imports/org/kde/plasma/plugins.qmltypes

substituting your paths, if different. You’ll note that your user probably doesn’t have privileges to write to that directory – so either run the command as root or generate the file in another directory and then copy it.

After refreshing/reloading the project in Qt Creator you will see the red underline has disappeared and Qt Creator is in a happy state. You can use this method with other components with missing plugins.qmltypes files; and use this with your custom C++ components as well.

How To Add QML Module with Plugins for Qt Creator

标签:style   http   io   color   ar   for   sp   on   art   

原文地址:http://my.oschina.net/leon0407/blog/338705

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!