OK, I've just refactoring it in this way and the problem is solved now.
It's sad that it's impossible to use self-variable in the binding
without getting boring warnings...
propertyintspeedColumnHoveredWidth:0
onCurrentTimeChanged:updateSpeedColumnHoveredWidth()
onDownloadsViewSpeedColumnHoveredChanged:updateSpeedColumnHoveredWidth()
onDownloadsViewSpeedColumnHoveredWidthChanged:updateSpeedColumnHoveredWidth()
onDownloadsViewSpeedColumnNotHoveredSinceTimeChanged:updateSpeedColumnHoveredWidth()
functionupdateSpeedColumnHoveredWidth()
{
//keephoveredwidthatmaxrecentvalue+3secondsafterleavinghoveredstate
varw=downloadsViewSpeedColumnHovered?
Math.max(d.speedColumnHoveredWidth,downloadsViewSpeedColumnHoveredWidth):
(d.currentTime-downloadsViewSpeedColumnNotHoveredSinceTime<3000)?d.speedColumnHoveredWidth:
0;
if(w!=d.speedColumnHoveredWidth)
d.speedColumnHoveredWidth=w;
}
On 4/2/2021 8:53 AM, Alexander Dyagilev wrote:
Hello,
I have a table. I change one column's size when user hovers it. Each
row in this column can require different "hovered" width. And I would
like it to return back in 3 seconds after mouse pointer left it.
So, I use this:
property bool viewSpeedColumnHovered: false
property int viewSpeedColumnHoveredWidth: 0
property double viewSpeedColumnNotHoveredSinceTime: 0
These properties are set outside of my control and the question is not
about them.
To achieve the above I use this property:
//keephoveredwidthatmaxrecentvalue+3secondsafterleavinghoveredstate
property int speedColumnHoveredWidth: downloadsViewSpeedColumnHovered ?
Math.max(speedColumnHoveredWidth, viewSpeedColumnHoveredWidth) :
(currentTime -
viewSpeedColumnNotHoveredSinceTime < 3000) ? speedColumnHoveredWidth :
0
When I hover the column first time - all is OK. But after 3 seconds
has passed, it returns to 0. My column became normal again. Then I
hover it again and get this strange message:
QML ViewHeaderColumnsWidthCalc: Binding loop detected for property
"speedColumnHoveredWidth"
I can't understand how can this be... If Math.max returns the property
itself (speedColumnHoveredWidth), then it should not generate
"changed" signal (property remains the same).
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest