PDA

View Full Version : Qt 4.7 QML/C++ Error : "Package not found" and "Module foobar is not installed"



kona_echinofu
25th October 2010, 21:12
Hey all!

I've been really excited to get onto the new QML with C++ bandwagon. However, when trying to follow the tutorials (built-in "Charts" example) I've been running into this issue.

It will not allow me to use Designer for QML, as well as add my own modules/C++ plugins.

I've wiped Qt, re-installed and even re-built. Still getting the same error.:(

I've looked over the internet to find only one guy who experienced the same problem and mentioned QmlObserver being used instead of QmlViewer, but I cannot find any option to change this?

I have the brand new Qt 4.7 and I've also tried it with the new Qt Creator 2.0.92 (2.1.0 beta 1)

Here's some images of what I'm seeing:

In Code Editing View:
http://gaiax.webs.com/1.jpg
In Designer View:
http://gaiax.webs.com/3.jpg

Has any body experienced this problem, if so how did you solve it?

Or are there any Qt experts that could help me out, would be much appreciated as I'm excited to start using QML with C++.:)

Thanks in advance.

kona_echinofu
26th October 2010, 14:30
Is anybody else experiencing this, or not?

kona_echinofu
26th October 2010, 21:31
Ok, this gets even more strange.

I can actually code with C++, create my own types for QML and invokable functions, however. Like in the original pictures they are appearing as invalid in Designer and Code editor... So it is valid at run-time but not whilst coding... What is going on?

wysota
27th October 2010, 19:09
Creator doesn't know anything about your packages and modules so it can't highlight or complete it. You need to write some additional code to make your modules recognizable by Creator.

kona_echinofu
1st November 2010, 13:32
Hi Wysota,

Thanks for your reply. Surely, if an example is provided by Qt to view, it should have all code written already. I haven't written this, it came with the Qt package.

wysota
2nd November 2010, 17:20
Surely, if an example is provided by Qt to view, it should have all code written already.
It's a coding example, not an example of highlighting qml syntax in Qt Creator which is not the only possible way one might be using Qt. If we try to understand it the way you do, Trolls would have to provide appropriate mechanisms for Visual Studio, Eclipse, KDevelop and all other possible code editors in the world.

kona_echinofu
2nd November 2010, 19:08
It's a coding example, not an example of highlighting qml syntax in Qt Creator which is not the only possible way one might be using Qt. If we try to understand it the way you do, Trolls would have to provide appropriate mechanisms for Visual Studio, Eclipse, KDevelop and all other possible code editors in the world.

I never looked at it that way. Its just frustrating not being able to use c++ with qml designer. Is there anywhere with a tutorial (not the one provided by qt as it doesn't function) or will I have to wait till full release to be able to use qml with c++ with ease?

wysota
2nd November 2010, 19:53
I never looked at it that way. Its just frustrating not being able to use c++ with qml designer. Is there anywhere with a tutorial (not the one provided by qt as it doesn't function) or will I have to wait till full release to be able to use qml with c++ with ease?

I have no idea what you mean.

kona_echinofu
2nd November 2010, 22:49
I mean setting up Qt 4.7 to allow me to use C++ with QML and QML Designer. At this moment in time, I'm unable to do so as when I create C++ classes and expose them to QML and use them, they work and the application will run, but I cannot use QML Designer as it does not recognise these classes as QML objects and gives me the errors you see in the images.

wysota
2nd November 2010, 22:58
I mean setting up Qt 4.7 to allow me to use C++ with QML and QML Designer.
QML and C++ are two different languages. You can't use them "together".


At this moment in time, I'm unable to do so as when I create C++ classes and expose them to QML and use them, they work and the application will run, but I cannot use QML Designer as it does not recognise these classes as QML objects and gives me the errors you see in the images.
Did you tell Creator about them by providing an appropriate extension plugin?

kona_echinofu
3rd November 2010, 00:00
Well I don't exactly mean together, but more in the sense of extending QML.

But regarding the PieCharts example, Creator should know about the Charts object through the code "qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");" which is in main.

From reading the examples and documentation, this should register the Charts Module and PieChart object for use within QML. When I run the application, the Chart appears correctly in the QML embedded within the C++ application.

However, Creator and Designer itself doesn't recognise it whilst in code/designer view.

Added after 8 minutes:

http://gaiax.webs.com/4.jpg

A visual to describe what I mean.

wysota
3rd November 2010, 00:35
Well I don't exactly mean together, but more in the sense of extending QML.

But regarding the PieCharts example, Creator should know about the Charts object through the code "qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");" which is in main.
Creator doesn't execute C++ code nor does it know what elements, its properties and such the "Charts" module might be exporting so putting any C++ statement won't have any effect on it.


From reading the examples and documentation, this should register the Charts Module and PieChart object for use within QML. When I run the application, the Chart appears correctly in the QML embedded within the C++ application.
If you start reading something, read until the end, please.

Chapter 6: Writing an Extension Plugin

kona_echinofu
3rd November 2010, 01:12
I did indeed read it through. However, Chapter 6 is different from what I'm working with now. In chapter 6, yes a plugin is created for use with a QML application. However, the chapters before that do not use a plugin. As stated in the Chapter 6 documentation
Currently the PieChart and PieSlice types are used by app.qml, which is displayed using a QDeclarativeView in a C++ application. An alternative way to use our QML extension is to create a plugin library to make it available to the QML engine.

This is what I'm trying to explain, Chapters 1-5 are not QML applications using a C++ plugin, but a C++ application using QDeclarativeView, displaying QML within a C++ application.

Added after 7 minutes:

Oh, it seems there is a problem. I have stumbled across this reply from a Nokia software developer.

So, I guess I will have to wait for a fix.

http://www.mail-archive.com/qt-qml@trolltech.com/msg01207.html

wysota
3rd November 2010, 08:59
Do you have the appropriate plugin at all? It won't work unless you have it, regardless of what Trolls fix in qmlobserver. Just like writing code for a custom widget is not enough to see the widget in Designer - you need an appropriate plugin for that. For QML there are three additional components and subset of them may be required in different situations - a qmlproject file, a qmldir file and a binary plugin.

Bruce Cichowlas
3rd November 2010, 20:53
I'm having a similar frustrating situation. I'm trying to get this example to run as a plugin to a simple QML project:

http://doc.qt.nokia.com/4.7/declarative-cppextensions-referenceexamples-adding.html

I'm using QTCreator 2.0.1 on Mac OS X. I feel as if I am very close. The plugin builds fine. I am thinking that all I need to do is to point the QML project file at the plugin. The plugin project is named "custom" so I've been trying things like this in the QML project file:


/* File generated by QtCreator */

import QmlProject 1.0

Project {
/* Include .qml, .js, and image files from current directory and subdirectories */
QmlFiles {
directory: "."
}
JavaScriptFiles {
directory: "."
}
ImageFiles {
directory: "."
}
/* List of plugin directories passed to QML runtime */
importPaths: [ "/Users/brucecichowlas/custom-build-desktop" ]
}

It seems as if this is there for my needs. Am I close? What do I need to do?

Thanks,
Bruce

wysota
3rd November 2010, 22:58
Do you have the respective qmldir file?

jonathanz
4th November 2010, 23:10
Hi All,

I have found the same problem as originally reported. I guess the test example is taken from the Qt 4.7.0 Reference Documentation on extending QML. The original test example does not have a .qmlproj file, so the problem is hidden.

Note that "app.qml" runs fine and great either within Qt Creator or with "qmlviewer". This is not an issue.

The real (minor?) issue is that, in Qt Creator's QML editor, both "Charts 1.0" and "PieChart" ARE underlined with a red wave line, which may give us the wrong impression that Qt does not recognize them, although they are actually accepted at runtime.

This is in contrast with the standard module "Qt 4.7" and standard QML element "Item": They are NOT underlined with a red wave line in Qt Creator's QML editor.

Is this a bug in Qt Creator 2.0.1? Should we report it to Nokia?

These are some further details about my setting:

1. In have created "qmldir" file with a single line like this:
plugin Charts ../plugins

2. I have added the following line in "app.qmlproject":
importPaths: ["../plugins"]

All these actions are to try to fix the issue by letting Qt Creator know the name and location of the shared library: ../plugins/libCharts.so. But there is no effect.

Thanks in advance for your reply,

kona_echinofu
5th November 2010, 00:16
Hi All,

I have found the same problem as originally reported. I guess the test example is taken from the Qt 4.7.0 Reference Documentation on extending QML. The original test example does not have a .qmlproj file, so the problem is hidden.

Note that "app.qml" runs fine and great either within Qt Creator or with "qmlviewer". This is not an issue.

The real (minor?) issue is that, in Qt Creator's QML editor, both "Charts 1.0" and "PieChart" ARE underlined with a red wave line, which may give us the wrong impression that Qt does not recognize them, although they are actually accepted at runtime.

This is in contrast with the standard module "Qt 4.7" and standard QML element "Item": They are NOT underlined with a red wave line in Qt Creator's QML editor.

Is this a bug in Qt Creator 2.0.1? Should we report it to Nokia?

These are some further details about my setting:

1. In have created "qmldir" file with a single line like this:
plugin Charts ../plugins

2. I have added the following line in "app.qmlproject":
importPaths: ["../plugins"]

All these actions are to try to fix the issue by letting Qt Creator know the name and location of the shared library: ../plugins/libCharts.so. But there is no effect.

Thanks in advance for your reply,

This is what I've been trying to explain throughout this thread. Its frustrating not being able to use C++ objects with QML Designer!

wysota
5th November 2010, 00:31
Is this a bug in Qt Creator 2.0.1?
No, it is not. If it doesn't work then it means your plugin, qmldir or qmlproject file (or all) is incorrect. Actually I can't speak of Creator 2.0.1, I've seen it work in 2.1 but I don't see a reason why this shouldn't work with 2.0.1 as well, the concept of qmldir files was known by the time when 2.0.1 was released.

People, do me a favour - look for errors in your own doings first before you start blaming others. Only when you have exhausted all possibilities that the problem lies on your side, start speaking of bugs in someone else's code or design and even then double check everything first in case you missed something. In my opinion that's a very good rule when it comes to software development.

kona_echinofu
5th November 2010, 00:43
http://doc.qt.nokia.com/4.7/declarative-cppextensions-referenceexamples-adding.html
Hm.. I guess there seems to be confusion on what EXACTLY is needed in order to use C++ objects within QML. As the example itself doesn't contain a qmlproject or qmldir file.

wysota
5th November 2010, 00:52
/me slaps his head

This is an example of extending QML, it doesn't involve Qt Creator in any way. Please understand Qt is not limited to Qt Creator. The example is perfectly valid if you use say... Notepad which doesn't understand qmldir, qmlproject or qml plugin files.

kona_echinofu
5th November 2010, 09:36
Thanks for clarifying that. I am new to QML and what may seem simple is new to me. Also I have only been using Qt for a short time. Afterall if we didn't ask questions we wouldn't get answers. I'm going to keep trying and will post my results.

wysota
5th November 2010, 09:42
Afterall if we didn't ask questions we wouldn't get answers.
It's good to do some reading before you start asking questions. You can't always rely somebody will do the research for you.

kona_echinofu
5th November 2010, 10:24
It's good to do some reading before you start asking questions. You can't always rely somebody will do the research for you.

This is true, but I wasn't looking for a straight answer to my problem, but rather some guidelines to what direction I should be heading to solve this problem. Which, you have provided me with, so thank you.

As stated before, I will take into consideration what I have learnt here, try again, and post my findings :)

wysota
5th November 2010, 10:52
The directions were provided in post #4 so what the remaining 20 posts are all about?

kona_echinofu
5th November 2010, 11:52
The directions were provided in post #4 so what the remaining 20 posts are all about?

Read them. Its a discussion, Bruce and Jonathan got involved :)

kona_echinofu
9th November 2010, 01:30
Well I've created my own qmlproject with my own qmldir and C++ extenstion (No longer using the build in example - Charts). I have had some good progress :) I don't know (or think) downloading Qt Creator 2.1 has helped, but I'm no longer getting the "Package not found" error message. However, a little problem remaining now is how to get Creator to recognise my types exported from C++.
Here's the code to my little test:

.qmlproject file:

/* File generated by QtCreator */

import QmlProject 1.0

Project {
/* Include .qml, .js, and image files from current directory and subdirectories */
QmlFiles {
directory: "."
}
JavaScriptFiles {
directory: "."
}
ImageFiles {
directory: "."
}
/* List of plugin directories passed to QML runtime */
importPaths: [ "../plugin" ]
}

.qml file:

import Qt 4.7
import "plugin"

Rectangle {
width: 200
height: 200
Text {
x: 66
y: 93
text: "Hello World"
}
MyItem{
id: testObj
}
}


qmldir file:

plugin plugin



Importing "plugin" is a folder I have used to contain the plugin I have built from C++. It contains the dll and relevent files for the plugin. Not sure how to get Creator to recognise the "Types" from this plugin though?

wysota
9th November 2010, 11:13
By "recognize" you mean syntax highlighting or code execution? Also, please post the code of your plugin.

kona_echinofu
10th November 2010, 01:25
By "recognize" you mean syntax highlighting or code execution?

I mean syntax highlighting. The application will run, just Creator won't recognise "MyItem".


Also, please post the code of your plugin.

Please find attached a ZIP of all files :)

SeTosha
29th November 2010, 17:37
I has same bug
Thats minimal example 5541


Build myitem/myitem.pro plugin as release
Open face/face.qmlproject
Open face/face.qml in editor mode and run it - all works fine in qmlviewer
Swith to design mode - can't load MyItem module

jonathanz
14th December 2010, 19:39
Thanks for the long discussions.

Now we should have a common understanding of the original problem: Qt Creator (or other QML editor tools) underlines in red any custom module name (like "import Charts 1.0") and custom QML element name (like "PieChart"). This gives us the false impression that there are syntax errors with these custom items, even though the QML code executes perfectly.

This does not happen with standard module names (like "import Qt 4.7") and standard QML element names (like "Rectangle").

So our request is: Do not underline custom module names and custom QML element names in red! Treat them the same as standard ones.

Maybe there is a Qt resource file (a .xml file, for example) that we don't know but where we can tell Qt Creator (or any other QML editor tools) that these are custom items?

Treating custom items the same as standard ones will encourage more developers to transition to QML.

- Jonathan

wysota
14th December 2010, 22:17
Maybe there is a Qt resource file (a .xml file, for example) that we don't know but where we can tell Qt Creator (or any other QML editor tools) that these are custom items?
There is no resource file, there is a plugin infrastructure and qmldir facility you need to use. It's a situation similar to using custom widgets in Designer. Feel free to extend Qt Creator with the capabilities of your choice, after all it is open source.

balisingh
26th August 2012, 00:10
I have a problem similar to this. I have a qt C++ qt plugin that works just fine if I build for the device the import statement in my qml application does not throw an error because the importPathList variable set in main.cpp point to where the plugin would be found when on the target device.
In qt creator "import plugin 1.0" is underlined as not found but building for target does cause any run-time errors.

However when i use QT designer environment it say the plugin is not found probably because environment paths are setup for the device.
I can qmake the plugin without errors. So what is the proper procedure to have QT Designer (or QT creator) to recognize my plug on the PC?

BTW, when i qmake the plugin its is kept here: "proc/19352/cwd/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/opt/plugin.so"

so i gotto add "proc/19352/cwd/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/opt/" to the qt creator path, How do i do that?