Support #2069
closedProcess scroll event in QTreeView
0%
Description
Hello! I want to process scrolling in QTreeView but there is no such signal.
I tried this:
wApp->declareJavaScriptFunction("onScroll", "function() { alert(\'Scroll event!\'); }");
tree->doJavaScript(tree->jsRef() + ".onscroll = " + wApp->javaScriptClass() + ".onScroll()");
but alert only shows up one time when widget creates and when I scroll view nothing happens.
How to make it working? May be I should use setJavaScriptMember() function?
Thanks in advance.
Updated by Koen Deforche over 11 years ago
- Status changed from New to Feedback
Hey Vital,
Problems with QTreeView should probably be reported with digia :-)
What you are trying to get from WTreeView is not possible however, the treeview is a complex widget and its internal layout (including the scrollable region) is not accessible.
Before we try to make it accessible, what is your use case for this?
Regards,
koen
Updated by Vitaly Volochay over 11 years ago
I have horizontal layout: on the left - WTreeView, on the right - WPaintedWidget which content depends on current scroll value. In other words I need to draw lines opposite tree nodes.
However I write this crazy js solution and it works:
wApp->declareJavaScriptFunction("SuperScroll",
"function() "
"{ console.log( \"Super scroll!\"); "
"var top = this.scrollTop;"
"console.log(\"this top:\", top);"
"console.log(\"this id:\", this.id)}");
treeView~~doJavaScript("var firstChild = " + treeView~~>jsRef() + ".children[0];"
"console.log(\"first child: \", firstChild.id);"
"var tree = firstChild.children[1];"
"console.log(\"tree: \", tree.id);"
"tree.addEventListener('scroll', " + wApp->javaScriptClass() + ".SuperScroll, false);");
I looked html dom hierarchy of WTreeView and find that second child of first child of WTreeView is proper scroll area, but I am a bit afraid of version problem if u change some code in WTreeView.
Updated by Koen Deforche over 11 years ago
Hey,
That sounds like a sensible use-case, indeed. I guess we the super-crazy hack would be simplified if we provide access to the widget that is the virtual scroll container --- that's probably a safe thing to do.
Regards,
koen
Updated by Vitaly Volochay over 11 years ago
Thank you, Koen, that would be nice with usage example.
Updated by Koen Deforche over 11 years ago
- Target version changed from 3.3.0 to 3.3.2
Updated by Koen Deforche almost 11 years ago
- Status changed from Feedback to Resolved
Updated by Koen Deforche almost 11 years ago
- Status changed from Resolved to Closed