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. how to make a reservation seat in qml ?
Forum Update on Monday, May 27th 2025

how to make a reservation seat in qml ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qtquickqmlc++
3 Posts 2 Posters 371 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.
  • Q Offline
    Q Offline
    qiuqiu
    wrote on last edited by
    #1

    hi, I've just learned about qml and qtquick
    Im about to making a reservation seat app in qml, what I want is when the seat clicked it will set the price and when its unclicked the price will reset,
    sorry for my english :)

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Some simple code like this should work:

      ColumnLayout {
        property real price: 0.0 // BTW. Using floating point for prices is a very bad idea! I use it here only as a simplification
        Label {
          text: qsTr("Price")
        }
      
        Label {
          text: price
        }
      
        GridView {
          model: 20
          spacing: 10
      
          delegate: Rectangle {
            property bool selected: true
            color: selected? "red" : "gray"
      
            MouseArea {
              anchors.fill: parent
              onClicked: { 
                if (selected) {
                  price += 15 
                } else {
                  price -= 15
                }
                selected = !selected
              }
          }
        }
      }
      

      It would be better to use some real model here, like list of objects or QAbstractItemModel. I've used just integer to make things simpler.

      ... and don't worry about your English, it's pretty good :-)

      (Z(:^

      Q 1 Reply Last reply
      2
      • sierdzioS sierdzio

        Some simple code like this should work:

        ColumnLayout {
          property real price: 0.0 // BTW. Using floating point for prices is a very bad idea! I use it here only as a simplification
          Label {
            text: qsTr("Price")
          }
        
          Label {
            text: price
          }
        
          GridView {
            model: 20
            spacing: 10
        
            delegate: Rectangle {
              property bool selected: true
              color: selected? "red" : "gray"
        
              MouseArea {
                anchors.fill: parent
                onClicked: { 
                  if (selected) {
                    price += 15 
                  } else {
                    price -= 15
                  }
                  selected = !selected
                }
            }
          }
        }
        

        It would be better to use some real model here, like list of objects or QAbstractItemModel. I've used just integer to make things simpler.

        ... and don't worry about your English, it's pretty good :-)

        Q Offline
        Q Offline
        qiuqiu
        wrote on last edited by
        #3

        @sierdzio thank you :))

        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