Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Some strange errors in a sample code

Some strange errors in a sample code

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • tomyT Offline
    tomyT Offline
    tomy
    wrote on last edited by tomy
    #1

    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.

    E 1 Reply Last reply
    0
    • tomyT tomy

      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.

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @tomy You need MenuPanel.qml which is found a bit later in that document.

      1 Reply Last reply
      1
      • E Offline
        E Offline
        Eeli K
        wrote on last edited by
        #3

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

        tomyT 1 Reply Last reply
        1
        • E Eeli K

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

          tomyT Offline
          tomyT Offline
          tomy
          wrote on last edited by
          #4

          @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?

          E 1 Reply Last reply
          0
          • tomyT tomy

            @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?

            E Offline
            E Offline
            Eeli K
            wrote on last edited by
            #5

            @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.

            1 Reply Last reply
            0
            • tomyT Offline
              tomyT Offline
              tomy
              wrote on last edited by
              #6

              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!

              E 1 Reply Last reply
              0
              • tomyT tomy

                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!

                E Offline
                E Offline
                Eeli K
                wrote on last edited by Eeli K
                #7

                @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.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved