What does the third parameter of Flickable::resizeContent() do?
-
Hey, I have a ListView which's content is resizing with the contentWidth/Height and I implemented a zoom functionality for the ListView. My zoom uses the resizeContent() method of the ListView, but I am not quiet sure what the 3rd argument does, the docs say: "Resizes the content to width x height about center.", where "center" is the third parameter.
My problem is that my zoom doesn't zoom towards my mouse pointer, which is what I want:
https://streamable.com/2d7ov1As you see, its not zooming towards my mouse pointer, this is my zoom method:
// Generate factors between 0.8 and 1.2 let factor = (((wheel.angleDelta.y / 120)+1) / 5 ) + 0.8; if (wheel.modifiers & Qt.ControlModifier) { let newWidth = listView.contentWidth * factor; // Prevent a too high/low zooms if (newWidth < listView.normalWidth / 6 || newWidth > listView.normalWidth * 5) { return; } listView.resizeContent(Math.round(newWidth), Math.round(newWidth / listView.currentItem.pageRatio), Qt.point(0,0)); listView.returnToBounds();
Might this third parameter help me here?
Thanks in advance -
@Creaperdown said in What does the third parameter of Flickable::resizeContent() do?:
Hey, I have a ListView which's content is resizing with the contentWidth/Height and I implemented a zoom functionality for the ListView. My zoom uses the resizeContent() method of the ListView, but I am not quiet sure what the 3rd argument does, the docs say: "Resizes the content to width x height about center.", where "center" is the third parameter.
My problem is that my zoom doesn't zoom towards my mouse pointer, which is what I want:
https://streampou.com/2d7ov1As you see, its not zooming towards my mouse pointer, this is my zoom method:
// Generate factors between 0.8 and 1.2 let factor = (((wheel.angleDelta.y / 120)+1) / 5 ) + 0.8; if (wheel.modifiers & Qt.ControlModifier) { let newWidth = listView.contentWidth * factor; // Prevent a too high/low zooms if (newWidth < listView.normalWidth / 6 || newWidth > listView.normalWidth * 5) { return; } listView.resizeContent(Math.round(newWidth), Math.round(newWidth / listView.currentItem.pageRatio), Qt.point(0,0)); listView.returnToBounds();
Might this third parameter help me here?
Thanks in advanceThe same thing happened to me. Please let me know if you find a solution to this problem.
-
Hey, I have a ListView which's content is resizing with the contentWidth/Height and I implemented a zoom functionality for the ListView. My zoom uses the resizeContent() method of the ListView, but I am not quiet sure what the 3rd argument does, the docs say: "Resizes the content to width x height about center.", where "center" is the third parameter.
My problem is that my zoom doesn't zoom towards my mouse pointer, which is what I want:
https://streamable.com/2d7ov1As you see, its not zooming towards my mouse pointer, this is my zoom method:
// Generate factors between 0.8 and 1.2 let factor = (((wheel.angleDelta.y / 120)+1) / 5 ) + 0.8; if (wheel.modifiers & Qt.ControlModifier) { let newWidth = listView.contentWidth * factor; // Prevent a too high/low zooms if (newWidth < listView.normalWidth / 6 || newWidth > listView.normalWidth * 5) { return; } listView.resizeContent(Math.round(newWidth), Math.round(newWidth / listView.currentItem.pageRatio), Qt.point(0,0)); listView.returnToBounds();
Might this third parameter help me here?
Thanks in advance@Creaperdown said in What does the third parameter of Flickable::resizeContent() do?:
My problem is that my zoom doesn't zoom towards my mouse pointer, which is what I want
Because you set x=0, y=0 as third parameter. Set your cursor coordinates instead.
-
@Creaperdown said in What does the third parameter of Flickable::resizeContent() do?:
My problem is that my zoom doesn't zoom towards my mouse pointer, which is what I want
Because you set x=0, y=0 as third parameter. Set your cursor coordinates instead.
@jsulm I have tried setting it to the mouse.x/y mapped to the relative position of the listview but it did not change any thing.
-
@Creaperdown said in What does the third parameter of Flickable::resizeContent() do?:
My problem is that my zoom doesn't zoom towards my mouse pointer, which is what I want
Because you set x=0, y=0 as third parameter. Set your cursor coordinates instead.
@jsulm I still didnt get it to work, I am trying this function:
function zoom(factor) { let newWidth = listView.contentWidth * factor; // Prevent from too high/low zooms if (newWidth < listView.normalWidth / 6 || newWidth > listView.normalWidth * 5) { return; } let mappedPoint = mapToItem(listView, Qt.point(mouseArea.mouseX, mouseArea.mouseY)); listView.resizeContent(Math.round(newWidth), Math.round(newWidth / listView.currentItem.pageRatio), mappedPoint ); listView.returnToBounds(); }
But this doesn't work either, it just moves to the top of the listview. Is this what you meant with putting in my cursor coords?
-
@jsulm I still didnt get it to work, I am trying this function:
function zoom(factor) { let newWidth = listView.contentWidth * factor; // Prevent from too high/low zooms if (newWidth < listView.normalWidth / 6 || newWidth > listView.normalWidth * 5) { return; } let mappedPoint = mapToItem(listView, Qt.point(mouseArea.mouseX, mouseArea.mouseY)); listView.resizeContent(Math.round(newWidth), Math.round(newWidth / listView.currentItem.pageRatio), mappedPoint ); listView.returnToBounds(); }
But this doesn't work either, it just moves to the top of the listview. Is this what you meant with putting in my cursor coords?
@Creaperdown said in What does the third parameter of Flickable::resizeContent() do?:
mouseArea
What is it? And what is the value of mappedPoint?
-
@Creaperdown said in What does the third parameter of Flickable::resizeContent() do?:
mouseArea
What is it? And what is the value of mappedPoint?
@jsulm mouseArea is a MouseArea which covers all the screen (because I don’t want the user to need to hover over the listview to be able to zoom).
The value of the mapped point is in the range of the ListView and seems to do what it is supposed to do. When hovering on the top left of the listview it’s (0|0), at the bottom right it’s the listviews width and height (middle-ish it might be around (520|400)