[Solved] QML-Type "is not a type" when starting application - Main QML-File does not see other QML-File(s)
-
After solving the big problem with getting QT Mobility compiled and running (http://qt-project.org/forums/viewthread/29008/) I am facing a new problem:
I am using Eclipse with PyDev and QT 4.7.4 with QT Mobility 1.2.
My App which I want to get run has the following structure:
TwitterCrawler.py
with the following main code:
@if name == "main":
frontend = os.path.join(os.path.realpath(os.path.dirname(file)), "frontend")
app = QApplication(sys.argv)
qmlRegisterType(Controller, "TwitterCrawler", 1, 0, "Controller")view = QDeclarativeView() view.setResizeMode(QDeclarativeView.SizeRootObjectToView) root = view.rootContext() view.setSource(os.path.join(frontend, "frontend.qml")) view.show() app.exec_() sys.exit() @
frontend/frontend.qml
frontend/PageStack.js
frontend/PageStack.qmlfrontend.qml contains the following code:
@import QtQuick 1.1
import TwitterCrawler 1.0
import QtMobility.location 1.2
import "tweets.js" as TweetsPageStack{ // line 26
id: rootPage
width: 900
...@This ends up with:
@D:\Daten\Eclipse\TwitterCrawler\frontend\frontend.qml:26:1: PageStack is not a type @The frontend folder also contains a frontend.qmlproject with the following code:
@import QmlProject 1.1Project {
mainFile: "frontend.qml"/* 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: [ "../exampleplugin" ]
}@
As this is a program which was not created by me and already worked at the developer who gave it to me, I am now not sure what I might have done wrong or what the developer did in another way...
-
I don't have experience with Qt in Python, or QtMobility, but first thing I would try is importing you PageStack.qml manualy in frontend.qml
@
...
import "PageStack.qml" as PageStackPageStack
@
And in main method I would try relative path (maybe in Python it is has to be absolute, but I have never tried Qt in Python):
@
view.setSource("frontend/frontend.qml"))
@ -
[quote author="portoist" date="1372840729"]
And in main method I would try relative path (maybe in Python it is has to be absolute, but I have never tried Qt in Python):
@view.setSource("frontend/frontend.qml"))@
[/quote]As you mentioned and I found out yesterday night, that's the solution ;)