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. Listview onclick event
Qt 6.11 is out! See what's new in the release blog

Listview onclick event

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 3 Posters 3.9k 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.
  • R Offline
    R Offline
    ReshmaS
    wrote on last edited by
    #1

    I have a listview with 5 items, onclicking them results in a rectangle with their properties. The starting point of the rectange is just beside the list. For instance if i clickon 5th element the rectangle is half sunk, as my width and height is limited. I want tat rectangle to start at a higher position: i tried to give x,y values but this does not work. I hope you have got my quesiton. If details are required, I will be more than happy to give them

    Thanks in advance

    Reshma

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dmcr
      wrote on last edited by
      #2

      The better way is to encapsulate the rectangle in the element, then set it visible only when necessary, in association with some state, for example.

      dmcr

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ReshmaS
        wrote on last edited by
        #3

        hmm okay.. I will try.. Also, I want a screen behind the rectange which disables the listelement, so that the user is unable to click on the elements. any idea how to go about.?

        Reshma

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dmcr
          wrote on last edited by
          #4

          Many way to do the job.
          A Mousearea with a onReleased : {} or, wich is the proper way, using index & currentIndex to set the state of each element.

          dmcr

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ReshmaS
            wrote on last edited by
            #5

            I tried to encapsulate the rectangle but the problem is, its within Component.I cannot alter the x and y inside the component.

            Reshma

            1 Reply Last reply
            0
            • R Offline
              R Offline
              ReshmaS
              wrote on last edited by
              #6

              @// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
              import QtQuick 1.1

              Rectangle {
              id:main
              width: 360
              height: 360

              Component
              {
              id:contactdelegate
              
              Item {
                          x: 5
                          height: 40
                          Row {
                              id: row1
                              spacing: 10
                              Rectangle {
                                  width: 40
                                  height: 40
                                  color: colorCode
                              }
              
                              Text {
                                  text: name
                                  anchors.verticalCenter: parent.verticalCenter
                                  font.bold: true
                              }
                          }
              
              
              Text{
                  id:t1
              
                  text :"HELLO"
              
              
              
              }
              

              }
              }

              ListModel {
                  id:listmodel
                          ListElement {
                              name: "Grey"
                              colorCode: "grey"
                          }
              
                          ListElement {
                              name: "Red"
                              colorCode: "red"
                          }
              
                          ListElement {
                              name: "Blue"
                              colorCode: "blue"
                          }
              
                          ListElement {
                              name: "Green"
                              colorCode: "green"
                          }
                      }
              
              
              
              ListView {
                  id: list_view1
                  x: 27
                  y: 62
                  clip:true
                  width: 110
                  height: 160
                  delegate: contactdelegate
                  model: listmodel
              }
              

              }
              @

              Is it possible for me to have the text "Hello" at the beginning of the main reactange at x,y:0 position??
              Thanks in advance!

              Reshma

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Julie1986
                wrote on last edited by
                #7

                I know this would be possible if u go outside the component and place it. But u want the text to be within the component.

                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