Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Slot Machine in Qt Quick
Forum Updated to NodeBB v4.3 + New Features

Slot Machine in Qt Quick

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 1.7k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    Hello, can I make slot game with QML? Is there an example of this, I found something like this, but I need to use Felgo for this, can't we do this with pure QML?

    https://felgo.com/doc/felgo-slotmachine/

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Any idea ?

      1 Reply Last reply
      0
      • ndiasN Offline
        ndiasN Offline
        ndias
        wrote on last edited by
        #3

        Hi @NullByte,

        Perhaps you can start by investigating the use of the tumbler component to make your slot machibe: https://doc.qt.io/qt-5/qml-qtquick-controls2-tumbler.html

        Regards

        ? 1 Reply Last reply
        0
        • ndiasN ndias

          Hi @NullByte,

          Perhaps you can start by investigating the use of the tumbler component to make your slot machibe: https://doc.qt.io/qt-5/qml-qtquick-controls2-tumbler.html

          Regards

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @ndias I don't know exactly how to do this can you make an example for me?

          ndiasN 1 Reply Last reply
          0
          • ? A Former User

            @ndias I don't know exactly how to do this can you make an example for me?

            ndiasN Offline
            ndiasN Offline
            ndias
            wrote on last edited by
            #5

            @NullByte : I don't have any example implementing thins. But, with little effort, you can generate a random number and set the currentIndex for every Tumbler component.
            But I'm not sure how you can increase the speed to have a movement effect when incrementing the currentIndex.
            he movement effect can also be done by quickly incrementing the currentIndex.

            import QtQuick
            import QtQuick.Window
            import QtQuick.Controls
            
            ApplicationWindow {
                property var numItens: 5
            
                Rectangle {
                    anchors.fill: parent
                    Row {
                        Tumbler {
                            id: tumbler1
                            model: numItens
                            wrap: true
                        }
                        Tumbler {
                            id: tumbler2
                            model: numItens
                            wrap: true
                        }
                        Tumbler {
                            id: tumbler3
                            model: numItens
                            wrap: true
                        }
                    }
            
                    Timer {
                        id: incTimer1
                        property var counter: 0
                        property var frequency: 2
                        interval: 1000 / frequency
                        repeat: true
                        running: counter != 0
                        onTriggered: {
                            tumbler1.currentIndex = counter % numItens;
                            counter = counter-1
                            console.debug(incTimer1.counter + " " + tumbler1.currentIndex)
                        }
                    }
            
                    MouseArea {
                        id: playArea
                        anchors.fill: parent
                        onPressed: {
                            incTimer1.startIndex = incTimer1.counter
                            incTimer1.counter = 5*incTimer1.frequency + Math.floor(Math.random() * numItens) // 5 seconds + X variable time
                            console.debug(incTimer1.counter)
                        }
                    }
                }
            }
            
            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