Customizing labs components
-
I was reading over http://doc.qt.io/qt-5/qtlabscontrols-customize.html#customizing-itemdelegate for automizing an ItemDelegate. almost all of the code on the referenced page includes references to 'control'. For example:
background: Rectangle { implicitWidth: 100 implicitHeight: 40 visible: control.pressed || control.highlighted color: control.pressed ? "#bdbebf" : "#eeeeee" }
Where background is a property of ItemDelegate.
But this code does not work. I get errors that 'ReferenceError: control is not defined'. I thought at first that perhaps 'control' was the id of the control containing this code, but, that doesn't seem to work either.
When I change 'control' to be the id of the component, I do not get errors, but the code doesn't work. In this example, the background never changes, even when clicked (I have an onClick that logs to console, so I know it's getting clicked).
So what is control in this context?
Thanks.
-
I've determined that 'control' is supposed to refer to the id of the containing control, in this case the ItemDelegate. So the color does get set while the element is pressed, but, not when it's not pressed. It this example, the color is set to '#eeeeee' while pressed, but is NOT '#dbdebf' while not pressed.
-
I had assumed that when the element was selected - in my case tapped on - that highlighted would equal true. But it doesn't.
I understand your response, Asking slightly differently then, what property does get set that I can use in this background component that will be true when it's the selected list element?