Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. create listView with certain items from array
QtWS25 Last Chance

create listView with certain items from array

Scheduled Pinned Locked Moved Unsolved General and Desktop
arraylistviewmodeldatamodel
1 Posts 1 Posters 668 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.
  • L Offline
    L Offline
    Ldweller
    wrote on last edited by
    #1

    Hello!

    I am trying to create a listView of names on selected calendar date(s), which if the date in the calendar matches, will display the userName in the listView;

    My array is created from a firebase read on userLogin, and using the for loop and image visibility i am adding a marker to dates in the array, how could i amend the loop or what would i add to as my ListModel to show this?

    I have tried many variations of things such as

    List View {
        model: arrayFromFireBase
    
            delegate: Text {text: modelData.name } }
    

    But am struggling to get it working! below is the code which applies to adding the date marker to my calendar, I am wondering if I need to alter the loop to apply to the name property also as my array looks like [{"name":"Edward","date":"2018-06-12"},{"name":"Dave","date":"2018-09-10"},{"name":"Tom","date":"2018-06-12"}] in the console. from This on the 6/12/18 there would be two names in the listView (Edward&Tom), whereas just the one name (Dave) on the 10/9

    Any help would be amazing!!!
    Thanks

    Main.qml:

        App {
    
        property var arrayFromFireBase: []
    
         onLoggedIn:  {
          firebaseDb.getUserValue("dates/selectedDates", {},
                                        function(success, key, value) {
                                        if(success) {
                                             for(var idx in value)
                                                arrayFromFireBase.push(new Date(value[idx].date).getTime())
                                        })}}
    
    
    CalendarPage.qml:
    
        Page {
        AppButton {
              id: saveButton
              text: "Save & Request"
                  onClicked: {
                      userData.selectedDates.push({"date": calendar.selectedDate});
                      console.log(JSON.stringify(userData));
                      firebaseDb.setUserValue("dates", userData)
                      }
               }
    
        property var userData: { 
                "selectedDates": [{}]
               }
    
        Image {
           visible: arrayFromFireBase.indexOf(styleData.date.getTime()) > -1
          }
        }
    
    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