refreshing Gridview components on button click
-
Hi,
I have a gridview which has 30-40 components. And i have a button on the screen, which when pressed changes the image source of the components. But the components which are visible on the gridview do not alter but as i scroll down, i find that the components which were not visible previously have altered image. And on scrolling back to previous position, the components which were not refreshed are now altered. In short the gridview components do not alter spontaneously. Any Help??
-
Hi,
I have a gridview which has 30-40 components. And i have a button on the screen, which when pressed changes the image source of the components. But the components which are visible on the gridview do not alter but as i scroll down, i find that the components which were not visible previously have altered image. And on scrolling back to previous position, the components which were not refreshed are now altered. In short the gridview components do not alter spontaneously. Any Help??
How do you actually change the image source of the components ?
-
Component { Image { id:folderImg width:140 height:175 source: selectAllFlag?"Assets/RecBtn2.png":"Assets/RecBtn1.png"; anchors.horizontalCenter: parent.horizontalCenter } }
where selectAllFlag is the status of the button.
-
Component { Image { id:folderImg width:140 height:175 source: selectAllFlag?"Assets/RecBtn2.png":"Assets/RecBtn1.png"; anchors.horizontalCenter: parent.horizontalCenter } }
where selectAllFlag is the status of the button.
@Sam_George just to understand, you can add mousearea to image and print the value of selectAllFlag on click. If selectAllFlag value fine add a handler for selectAllFlag in delegate and set the source of the image on it. Like onSelectAllFlagChanged:
selectAllFlag ? source = second : source= first -
@Sam_George just to understand, you can add mousearea to image and print the value of selectAllFlag on click. If selectAllFlag value fine add a handler for selectAllFlag in delegate and set the source of the image on it. Like onSelectAllFlagChanged:
selectAllFlag ? source = second : source= firsthi
@Yaswanth said in refreshing Gridview components on button click:
Like onSelectAllFlagChanged:
selectAllFlag ? source : second : firstconditionnal operator will not work like this (use "=" for assign, not ":" ), correct verion is
onSelectAllFlagChanged: selectAllFlag ? source= second : source = first
-
hi
@Yaswanth said in refreshing Gridview components on button click:
Like onSelectAllFlagChanged:
selectAllFlag ? source : second : firstconditionnal operator will not work like this (use "=" for assign, not ":" ), correct verion is
onSelectAllFlagChanged: selectAllFlag ? source= second : source = first
-
Why are you changing the delegate directly ? You can change model. It should update the view. It is auto taken care.
If you still would like to do what you wanted -
Changing directly in component will not help. Delegate are individual objects and source is already set with your image. If you change in component, it will not change source of already created objects. So when you scroll down, new delegate objects are getting created. Hence you will see the new image. When you scroll back, old delegate objects would have been destroyed. So it is creating new objects. Hence you will see new images. If you want to change the existing delegate object, get the reference of all the child objects. All the delegate objects are parented to contentItem. So get all the children of contentItem and update them. -
Thank you all,
It worked. I made one extra property in Component Item which gets updated whenever the selectAllFlag status changes. So I added a handler for this new variable inside the Component Item which on change changes the source of the image. Thank you all once again..