ChallengeTest.qml Example File

 import Felgo 3.0
 import QtQuick 2.0

 // required so the ChallengeView is known, but only during development
 import "."


 TestBase {

   // the challengeView is set as the challengeDelegate for FelgoGameNetwork
   property alias challengeView: challengeView

   property alias friendsView: challengeView.friendsView

   property variant gameNetworkItem: gameNetwork

   property int lastChallengeId: -1

   ChallengeView {
     id: challengeView
     anchors.fill: parent

     // this is only set to true in this test, because we want to display the back button and background of ListView
     // a real game should add own back buttons, and thus this is set to false by default
     debugMode: true

   // NOTE: this is just for quick testing - a real game initiates a call to submit the scores in a different place probably
   // but use the lastChallengeId as shown with the Connections element below!

   Column {
     visible: challengeView.state === "challengeOverview"

     anchors.bottom: parent.bottom

     Text {
       color: "white"
       text: "lastChallengeId: " + lastChallengeId

     SimpleButton {
       text: "Submit score to lastChallengeId"
       onClicked: {

         // if no challengeId was created, set it to empty
         if(lastChallengeId === -1)

         // submit it to the current leaderboard (or rather set it to the "challenges" leaderboard to avoid modifying the leaderboard scores!?)
         // the challengeIds is an array property, so only send it to one

         // instead, use the lastChallengeId property, which is also used when a challenge is accepted, not only created
         //gameNetwork.reportScore(Math.round(scoreSlider.value), "challenges", [])
         gameNetwork.reportScore(Math.round(scoreSlider.value), "challenges", [lastChallengeId])
     Row {
       spacing: 20

       GameSlider {
         id: scoreSlider
         minimumValue: -1000
         maximumValue: 1000
         value: 10
         width: 200
         height: 20

       Text {
         text: Math.round(scoreSlider.value)
         color: "white"

     // this is only for debugging, to see all challenges with all states in the log output
     SimpleButton {
       text: "Receive all user challenges (see log output)"
       onClicked: {


   // is created in ChallengeView!
 //  FriendsView {
 //    id: friendsView
 //    anchors.fill: parent
 //  }

   Connections {
     target: gameNetworkItem

     onChallengeCreated: {

       console.debug("onChallengeCreated:", JSON.stringify(challengeData))

       // use the to submit the score to it
       nativeUtils.displayMessageBox("Challenge created", "You can now submit a score to the challenge")
       challengeView.state = "challengeOverview"

       lastChallengeId =

     onChallengeWithScoreSubmitted: {
       console.debug("onChallengeWithScoreSubmitted:", JSON.stringify(challengeData))
       nativeUtils.displayMessageBox("Challenge score submitted", "Waiting for the friend to complete the challenge")

       lastChallengeId = -1

     onChallengeAccepted: {
       console.debug("onChallengeAccepted:", JSON.stringify(challengeData))
       nativeUtils.displayMessageBox("Challenge was accepted", "Submit a score to the challenge to complete it")

       lastChallengeId =

     onChallengeCompleted: {
       console.debug("onChallengeCompleted:", JSON.stringify(challengeData))
       nativeUtils.displayMessageBox("Challenge completed", "Winner is: " + + ", with score ")

       lastChallengeId = -1

     onLastQueriedUserChallengeListChanged: {

       console.debug("onLastQueriedUserChallengeListChanged to:", JSON.stringify(gameNetwork.lastQueriedUserChallengeList) )
       //challengeList.visible = true


Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support