[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:

    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()
    root = view.rootContext()
    view.setSource(os.path.join(frontend, "frontend.qml")) 
    sys.exit()        @


    frontend.qml contains the following code:
    @import QtQuick 1.1
    import TwitterCrawler 1.0
    import QtMobility.location 1.2
    import "tweets.js" as Tweets

    PageStack{ // 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.1

    Project {
    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 PageStack

    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):

  • [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):

    As you mentioned and I found out yesterday night, that's the solution ;)

  • Thats great!:) You can mark this as solved by editing your topic and adding [Solved] to the title.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.