Qt6 topics merged with General

how to make a reservation seat in qml ?

  • 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 :)

  • Moderators

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

  • @sierdzio thank you :))

Log in to reply