Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to scale to the items of scrollview for qml
Qt 6.11 is out! See what's new in the release blog

how to scale to the items of scrollview for qml

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 608 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.
  • J Offline
    J Offline
    jimfar
    wrote on last edited by
    #1

    ApplicationWindow {
    id: mainWindow
    // title: qsTr("AutoResize")
    width: 800
    height: 600
    visible: true
    ScrollView {
    id: control

        width:  parent.width
        height: parent.height
        focus: true
        MouseArea{
            id: dragRegion
            drag.target: control
            drag.axis: "XAxis"
            drag.minimumX: -9999999999999
            drag.minimumY: -9999999999999
            drag.maximumX: 9999999999999 //parentw - inputoutput.width
            drag.maximumY: 9999999999999// parenth - inputoutput.height
            anchors.fill: parent
            property point origin:Qt.point(0,0)
            property point clickPos : "0,0"
            property point lastPos : "0,0"
             onPressed: {
               drag.axis = Drag.XAndYAxis
               origin = Qt.point(mouse.x, mouse.y)
    
              }
              onPositionChanged: {
                   switch (drag.axis) {
                   case Drag.XAndYAxis:
                       var curpos=Qt.point(mouse.x, mouse.y)
                       var deltapos=curpos-lastPos ;
                        control.contentItem.x  += deltapos.y
                        control.contentItem.y+= deltapos.x
                      
                       break
                   }
    
               }
    

    onWheel : {

                                if (wheel.modifiers & Qt.ControlModifier) {
                                      console.log("inputoutput"  )
                                             if (wheel.angleDelta.y > 0)
                                                 control.contentItem.scale += 0.2;
                                             else if (control.contentItem.scale - 0.2 > 0.2)
                                                 control.contentItem.scale -= 0.2;
                                             else
                                               {
                                                  if(control.contentItem.scale>0.05)
                                                    control.contentItem.scale -= 0.01;
                                               }
                                         }
    
                         }
        }
    

    function loadInputOutput(i) {

                       var component = Qt.createComponent("Button.qml");
                       if (component.status == Component.Ready) {
                           var InputOutput = component.createObject(control);
                           InputOutput.parentw=parent.width
                           InputOutput.parenth=parent.height
                           InputOutput.index=i;
                           InputOutput.x=i*(InputOutput.width+20);
                           return (InputOutput.width+20);
                       }
                   }
    
    
               Component.onCompleted:
                {
                   var i=0;
                     var totallength=0;
                   totallength=0;
                   for(  i=0;i<2000;i++)
                         totallength+= loadInputOutput(i);
    
    
                }
    

    }

    i wanna to scale the items within Button.qml but not work

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jimfar
      wrote on last edited by
      #2

      anyone has some advice

      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