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. With Respect To ScrollBar To Rectangle
Forum Updated to NodeBB v4.3 + New Features

With Respect To ScrollBar To Rectangle

Scheduled Pinned Locked Moved QML and Qt Quick
27 Posts 2 Posters 9.5k Views 2 Watching
  • 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.
  • Pradeep KumarP Pradeep Kumar

    @p3c0

    and one more i have posted regarding listview, key up pressed and key down pressed

    Pradeep KumarP Offline
    Pradeep KumarP Offline
    Pradeep Kumar
    wrote on last edited by p3c0
    #5

    @Pradeep-Kumar.M

    and one more thing i want to the difference between contentWidth, contentHeight, contentX, contentY.

    i have a sample code, please look into it.

    import QtQuick 2.4
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        width: 300
        height: 300
        id:win
        Flickable {
            id: flick
            width: 80; height: 80
            contentWidth: image.width
            contentHeight: image.height
            contentX: image.x
            contentY: image.y
    //        contentY: 100
    
            Image {
                id: image;
                width: 50
                height: 50
                x: 50
                y: 100
                source: "qrc:/new/prefix1/logo.png"
            }
        }
    }
    

    Pradeep Kumar
    Qt,QML Developer

    p3c0P 1 Reply Last reply
    0
    • Pradeep KumarP Pradeep Kumar

      @Pradeep-Kumar.M

      and one more thing i want to the difference between contentWidth, contentHeight, contentX, contentY.

      i have a sample code, please look into it.

      import QtQuick 2.4
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 300
          height: 300
          id:win
          Flickable {
              id: flick
              width: 80; height: 80
              contentWidth: image.width
              contentHeight: image.height
              contentX: image.x
              contentY: image.y
      //        contentY: 100
      
              Image {
                  id: image;
                  width: 50
                  height: 50
                  x: 50
                  y: 100
                  source: "qrc:/new/prefix1/logo.png"
              }
          }
      }
      
      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #6

      @Pradeep-Kumar.M x and y are for positions while width and height are for dimensions.

      157

      Pradeep KumarP 1 Reply Last reply
      1
      • p3c0P p3c0

        @Pradeep-Kumar.M x and y are for positions while width and height are for dimensions.

        Pradeep KumarP Offline
        Pradeep KumarP Offline
        Pradeep Kumar
        wrote on last edited by
        #7

        @p3c0
        import QtQuick 2.4
        import QtQuick.Window 2.2

        Window {
        id: win
        visible: true
        width: 700
        height: 500
        Rectangle
        {
        id: rect
        width: t1.font.pixelSize * 50
        height: t1.font.pixelSize * 10
        color: "pink"
        Text {
        id: t1
        text: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjaaaaaaaaaaa"
        }
        }
        }

        as text size increases rectangle has to increase simultaneously , but in this case, its not increasing.

        Pradeep Kumar
        Qt,QML Developer

        Pradeep KumarP 1 Reply Last reply
        0
        • Pradeep KumarP Pradeep Kumar

          @p3c0
          import QtQuick 2.4
          import QtQuick.Window 2.2

          Window {
          id: win
          visible: true
          width: 700
          height: 500
          Rectangle
          {
          id: rect
          width: t1.font.pixelSize * 50
          height: t1.font.pixelSize * 10
          color: "pink"
          Text {
          id: t1
          text: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjaaaaaaaaaaa"
          }
          }
          }

          as text size increases rectangle has to increase simultaneously , but in this case, its not increasing.

          Pradeep KumarP Offline
          Pradeep KumarP Offline
          Pradeep Kumar
          wrote on last edited by
          #8

          @p3c0

          and one more thing it has to increase dynamically, with respect to text, please help.

          Pradeep Kumar
          Qt,QML Developer

          p3c0P 1 Reply Last reply
          0
          • Pradeep KumarP Pradeep Kumar

            @p3c0

            and one more thing it has to increase dynamically, with respect to text, please help.

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #9

            @Pradeep-Kumar.M hmm you meant length not size. Well in that case you will need get text length and bind it with some multiplier.
            Its better to use a TextArea here. Isn't it ?

            157

            Pradeep KumarP 1 Reply Last reply
            1
            • p3c0P p3c0

              @Pradeep-Kumar.M hmm you meant length not size. Well in that case you will need get text length and bind it with some multiplier.
              Its better to use a TextArea here. Isn't it ?

              Pradeep KumarP Offline
              Pradeep KumarP Offline
              Pradeep Kumar
              wrote on last edited by
              #10

              @p3c0

              because data is coming from c++ class thats y, inserting it to rectangle directly . if so how to find text length, do we have length method for text, i didnt find it.

              Pradeep Kumar
              Qt,QML Developer

              p3c0P Pradeep KumarP 2 Replies Last reply
              0
              • Pradeep KumarP Pradeep Kumar

                @p3c0

                because data is coming from c++ class thats y, inserting it to rectangle directly . if so how to find text length, do we have length method for text, i didnt find it.

                p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #11

                @Pradeep-Kumar.M Yes. Use length.

                157

                1 Reply Last reply
                1
                • Pradeep KumarP Pradeep Kumar

                  @p3c0

                  because data is coming from c++ class thats y, inserting it to rectangle directly . if so how to find text length, do we have length method for text, i didnt find it.

                  Pradeep KumarP Offline
                  Pradeep KumarP Offline
                  Pradeep Kumar
                  wrote on last edited by
                  #12

                  @p3c0

                  thank u for example of scrollbar to rectangle, it worked, one issue in it is ,
                  when i drag down, scrollbar moving upwards, i dont want in that fashion, drag should be with respect to scrollbar, not opposite, please help me.

                  Pradeep Kumar
                  Qt,QML Developer

                  p3c0P 1 Reply Last reply
                  0
                  • Pradeep KumarP Pradeep Kumar

                    @p3c0

                    thank u for example of scrollbar to rectangle, it worked, one issue in it is ,
                    when i drag down, scrollbar moving upwards, i dont want in that fashion, drag should be with respect to scrollbar, not opposite, please help me.

                    p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #13

                    @Pradeep-Kumar.M Must be some problem in your code. Try doing same as done in that example.

                    157

                    Pradeep KumarP 1 Reply Last reply
                    0
                    • p3c0P p3c0

                      @Pradeep-Kumar.M Must be some problem in your code. Try doing same as done in that example.

                      Pradeep KumarP Offline
                      Pradeep KumarP Offline
                      Pradeep Kumar
                      wrote on last edited by
                      #14

                      @p3c0

                      same thing i did it, will you please try, i want the scrollbar to have dragged with respect to mouse simulateonusly, not in opposite fashion, i tried,

                      Pradeep Kumar
                      Qt,QML Developer

                      p3c0P 1 Reply Last reply
                      0
                      • Pradeep KumarP Pradeep Kumar

                        @p3c0

                        same thing i did it, will you please try, i want the scrollbar to have dragged with respect to mouse simulateonusly, not in opposite fashion, i tried,

                        p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #15

                        @Pradeep-Kumar.M Can you explain it w.r.t to that example ? That example works fine as expected.

                        157

                        Pradeep KumarP 1 Reply Last reply
                        1
                        • p3c0P p3c0

                          @Pradeep-Kumar.M Can you explain it w.r.t to that example ? That example works fine as expected.

                          Pradeep KumarP Offline
                          Pradeep KumarP Offline
                          Pradeep Kumar
                          wrote on last edited by
                          #16

                          @p3c0

                          code is working fine, but the thing is scrollbar has to move w.r.t to mouse, when i want to scroll, for example in this forum if u want to scroll up, u will move your mouse up, w.r.t to scrollbar, but in the example case moving mouse upwards, scrolling takes place downwards, i mean to say opposite direction.

                          Pradeep Kumar
                          Qt,QML Developer

                          p3c0P 1 Reply Last reply
                          0
                          • Pradeep KumarP Pradeep Kumar

                            @p3c0

                            code is working fine, but the thing is scrollbar has to move w.r.t to mouse, when i want to scroll, for example in this forum if u want to scroll up, u will move your mouse up, w.r.t to scrollbar, but in the example case moving mouse upwards, scrolling takes place downwards, i mean to say opposite direction.

                            p3c0P Offline
                            p3c0P Offline
                            p3c0
                            Moderators
                            wrote on last edited by
                            #17

                            @Pradeep-Kumar.M Nope. If you scroll down the scrollbar moves down and ofcourse the image will go up and v.v. That's the intended behaviour.

                            157

                            Pradeep KumarP 2 Replies Last reply
                            0
                            • p3c0P p3c0

                              @Pradeep-Kumar.M Nope. If you scroll down the scrollbar moves down and ofcourse the image will go up and v.v. That's the intended behaviour.

                              Pradeep KumarP Offline
                              Pradeep KumarP Offline
                              Pradeep Kumar
                              wrote on last edited by
                              #18

                              @p3c0

                              hm k kk

                              Pradeep Kumar
                              Qt,QML Developer

                              1 Reply Last reply
                              0
                              • p3c0P p3c0

                                @Pradeep-Kumar.M Nope. If you scroll down the scrollbar moves down and ofcourse the image will go up and v.v. That's the intended behaviour.

                                Pradeep KumarP Offline
                                Pradeep KumarP Offline
                                Pradeep Kumar
                                wrote on last edited by
                                #19

                                @p3c0

                                and one more if we have implementation that works with keys press,
                                will it work for mouse area on clicked?.

                                Pradeep Kumar
                                Qt,QML Developer

                                p3c0P 1 Reply Last reply
                                0
                                • Pradeep KumarP Pradeep Kumar

                                  @p3c0

                                  and one more if we have implementation that works with keys press,
                                  will it work for mouse area on clicked?.

                                  p3c0P Offline
                                  p3c0P Offline
                                  p3c0
                                  Moderators
                                  wrote on last edited by
                                  #20

                                  @Pradeep-Kumar.M Yes should work. Create a function and call that function when required.

                                  157

                                  Pradeep KumarP 1 Reply Last reply
                                  0
                                  • p3c0P p3c0

                                    @Pradeep-Kumar.M Yes should work. Create a function and call that function when required.

                                    Pradeep KumarP Offline
                                    Pradeep KumarP Offline
                                    Pradeep Kumar
                                    wrote on last edited by
                                    #21

                                    @p3c0

                                    you mean to say create function form ex: function sample()
                                    {
                                    // implementation
                                    }

                                    mouse area{
                                    anchors.fill: id
                                    onclicked
                                    {
                                    sample()
                                    }
                                    }

                                    Pradeep Kumar
                                    Qt,QML Developer

                                    p3c0P 1 Reply Last reply
                                    0
                                    • Pradeep KumarP Pradeep Kumar

                                      @p3c0

                                      you mean to say create function form ex: function sample()
                                      {
                                      // implementation
                                      }

                                      mouse area{
                                      anchors.fill: id
                                      onclicked
                                      {
                                      sample()
                                      }
                                      }

                                      p3c0P Offline
                                      p3c0P Offline
                                      p3c0
                                      Moderators
                                      wrote on last edited by
                                      #22

                                      @Pradeep-Kumar.M Yes, so that same function can be called from Keys and MouseArea. No need to duplicate the code.

                                      157

                                      Pradeep KumarP 1 Reply Last reply
                                      0
                                      • p3c0P p3c0

                                        @Pradeep-Kumar.M Yes, so that same function can be called from Keys and MouseArea. No need to duplicate the code.

                                        Pradeep KumarP Offline
                                        Pradeep KumarP Offline
                                        Pradeep Kumar
                                        wrote on last edited by
                                        #23

                                        @p3c0

                                        what i taught was if there is implementation for keys event
                                        , their will be different implementation for mousearea alse

                                        Pradeep Kumar
                                        Qt,QML Developer

                                        p3c0P 1 Reply Last reply
                                        0
                                        • Pradeep KumarP Pradeep Kumar

                                          @p3c0

                                          what i taught was if there is implementation for keys event
                                          , their will be different implementation for mousearea alse

                                          p3c0P Offline
                                          p3c0P Offline
                                          p3c0
                                          Moderators
                                          wrote on last edited by
                                          #24

                                          @Pradeep-Kumar.M Ofcourse you will need to define a MouseArea as well as Keys.onUpPressed. But if the code that moves the scrollbar is similar then no need to duplicate it. Just put it in the function and call that function.

                                          157

                                          Pradeep KumarP 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