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. Simple QML visual string list need.
Forum Updated to NodeBB v4.3 + New Features

Simple QML visual string list need.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 1.1k 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.
  • V Offline
    V Offline
    veenusav
    wrote on 22 Nov 2017, 09:53 last edited by
    #1

    I tried but it is not showing any selection. even a text bolding is enough.
    If you can point a standard sample will be good. now i am refering stringlistmodel of Qt 5.9

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 22 Nov 2017, 20:59 last edited by
      #2

      Hi,

      Do you mean something like described here ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veenusav
        wrote on 23 Nov 2017, 08:34 last edited by
        #3

        not exactly. Basically I want a list in traditional way where you can see a selected item.
        I think I have done it with this modification. May be it is a workaround. please see this here.
        == code when I dont have selection indication ==

        import QtQuick 2.0
        ListView {
            width: 100; height: 100
        
            model: myModel
            delegate: Rectangle {
                height: 25
                width: 100
                Text { text: modelData }
            }
        }
        

        == code now; now I can see clicktime selection ==

        import QtQuick 2.0
        import QtQuick.Controls 2.2
        ListView {
            width: 100; height: 100
        
            model: myModel
            delegate: ItemDelegate {
                height: 25
                width: parent.width
                Text { text: modelData }
            }
        }
        

        I am not sure whether ItemDelegate is the right way to solve this. Please advise if there is another method. still it is only showing selection at the time of click. it is not persisting as I have selected that item in the list.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          ODБOï
          wrote on 23 Nov 2017, 23:43 last edited by
          #4

          @veenusav hello,
          do you want to select multiple items in your list ?

          This is an exemple with only one selectable item,but you can easily modify it to be able to select multiple items
          I hope it will help you

          LA
          import QtQuick 2.6
          import QtQuick.Window 2.2
          import QtQuick.Controls 2.0

          Window {
          visible: true
          width: 640
          height: 480

          ListView {
              id:list
              width: 100; height: 100
          
              property int _ind:1
              model: myModel
          
              currentIndex: _ind
          
              delegate: Rectangle {
                          id:item
                          height: 25
                          color: ListView.isCurrentItem ? "black" : "red" 
                          width: parent.width
                          Text{
                                 color: item.ListView.isCurrentItem ? "red" : "black"  
                                 text: name
                          }
                          MouseArea{
                              anchors.fill: parent
                              onClicked: {
                                      
                                      list._ind = index
          
                              }
                          }
                      }
          }
          
          ListModel{
              id:myModel
              ListElement{
                  name : "Item1"
                  }
              ListElement{
                  name : "Item2"
                  }
              ListElement{
                  name : "Item3"
                  }
              ListElement{
                  name : "Item4"
                  }
          }
          

          }

          1 Reply Last reply
          0
          • 6 Offline
            6 Offline
            6thC
            wrote on 24 Nov 2017, 04:10 last edited by
            #5

            Have you seen the highlight examples in the Qt Creator example project "Qt Quick Examples - Views"?

            http://doc.qt.io/qt-5/qtquick-views-example.html

            It may put you on track?

            1 Reply Last reply
            0

            1/5

            22 Nov 2017, 09:53

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved