Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. What does the third parameter of Flickable::resizeContent() do?
Forum Updated to NodeBB v4.3 + New Features

What does the third parameter of Flickable::resizeContent() do?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 663 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Creaperdown
    wrote on last edited by
    #1

    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/2d7ov1

    As 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

    jsulmJ 1 Reply Last reply
    0
    • P Offline
      P Offline
      pickdiscipline
      wrote on last edited by
      #2

      @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/2d7ov1

      As 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

      The same thing happened to me. Please let me know if you find a solution to this problem.

      1 Reply Last reply
      0
      • C Creaperdown

        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/2d7ov1

        As 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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @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.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        ? C 2 Replies Last reply
        0
        • jsulmJ jsulm

          @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.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • jsulmJ jsulm

            @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.

            C Offline
            C Offline
            Creaperdown
            wrote on last edited by Creaperdown
            #5

            @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?

            jsulmJ 1 Reply Last reply
            0
            • C Creaperdown

              @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?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Creaperdown said in What does the third parameter of Flickable::resizeContent() do?:

              mouseArea

              What is it? And what is the value of mappedPoint?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Creaperdown said in What does the third parameter of Flickable::resizeContent() do?:

                mouseArea

                What is it? And what is the value of mappedPoint?

                C Offline
                C Offline
                Creaperdown
                wrote on last edited by Creaperdown
                #7

                @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)

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved