Some strange errors in a sample code
-
Hi guys,
Through searching the Web much and much, I found a sample program named Qt_Quick_Game_Programming_1_0.pdf and then create a project as follows:
Using Qt Creator 5.8 on Windows:
File
>
New File or Project>
Qt Quick Application>
Giving a name>
Minimal Required Qt version: Qt 5.6>
deselecting with ui.qml file>
Next>
Choosing 3 kits (Arm, x86 and Desktop)>
Next and finish.After these I opened the file "main.qml" and read and then pasted the code below:
import QtQuick 2.6 Item { width: 800 height: 480 // *** Game View *** GameView { id: gameView // Gameview is disabled when gameViewHider is shown enabled: gameViewHider.state == "hide" } // *** Game View Hider *** Rectangle { id: gameViewHider anchors.fill: parent color: "black" opacity: 0.7 states: [ State { name: "hide" when: menuPanel.state == "hide" PropertyChanges { target: gameViewHider opacity: 0 } } ] transitions: Transition { NumberAnimation { properties: "opacity" duration: 400 } } } // *** Main Menu panel *** MenuPanel { id: menuPanel } }
Now when running it by the Desktop kit, I get errors as in this image.
I have two questions please:
1- Have I created the project through the wizard correctly?
2- Why do I get these errors please?Thanks so much for your help.
-
Hi guys,
Through searching the Web much and much, I found a sample program named Qt_Quick_Game_Programming_1_0.pdf and then create a project as follows:
Using Qt Creator 5.8 on Windows:
File
>
New File or Project>
Qt Quick Application>
Giving a name>
Minimal Required Qt version: Qt 5.6>
deselecting with ui.qml file>
Next>
Choosing 3 kits (Arm, x86 and Desktop)>
Next and finish.After these I opened the file "main.qml" and read and then pasted the code below:
import QtQuick 2.6 Item { width: 800 height: 480 // *** Game View *** GameView { id: gameView // Gameview is disabled when gameViewHider is shown enabled: gameViewHider.state == "hide" } // *** Game View Hider *** Rectangle { id: gameViewHider anchors.fill: parent color: "black" opacity: 0.7 states: [ State { name: "hide" when: menuPanel.state == "hide" PropertyChanges { target: gameViewHider opacity: 0 } } ] transitions: Transition { NumberAnimation { properties: "opacity" duration: 400 } } } // *** Main Menu panel *** MenuPanel { id: menuPanel } }
Now when running it by the Desktop kit, I get errors as in this image.
I have two questions please:
1- Have I created the project through the wizard correctly?
2- Why do I get these errors please?Thanks so much for your help.
-
-
In general, GameView, Rectangle etc. are types, by using them in your qml files you create objects of those types. The types either come with Qt (Item, Rectangle etc.) or are defined in you program in their own qml files (here GameView, MenuPanel).
-
@Eeli-K
thank you very much.
So I have created the project correctly, yes?
And what I need is "not running the app now" but instead continuing it, yes?@tomy You just have to add the missing files and implement the types there before you can run it. They are in the .tar.gz package given in the web article. In Qt Creator use the right mouse button on qml.qrc and add a file. You can copy the file from the package and add it as existings file or create from scratch and copy or type the contents.
-
thank you.
It's the third time I ask this question: Have I created the project correctly?
And also I don't have a .qrc file on my project to right click on it!
@tomy In the left side panel of Qt Creator you have the project tree view. You should have you main.qml file under qml.qrc in the project tree (choose the "Projects" view if it's e.g. "Open Documents"). The created project should work as is, as long as you add new files using the RMB menu (or add them manually to the qrc file).
Edit: I have tested with Qt Creator which comes with Qt 5.8 and if you create the project with the wizard you will have the qml.qrc file.
Second edit: the file is under Resources.