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. [Solved] How to use qml to display a specified part of a picture
QtWS25 Last Chance

[Solved] How to use qml to display a specified part of a picture

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 7.5k 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.
  • B Offline
    B Offline
    buaacss
    wrote on last edited by
    #1

    could anyone tall me how to do this in qml? Just like background-position in CSS.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      Can you explain a bit more? You want to display a piture in some position on the screen or you want to display some part of image?

      Taka a look at "Image.fillMode":http://doc.qt.nokia.com/4.7-snapshot/qml-image.html#fillMode-prop

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on last edited by
        #3

        Hmmm, not sure of any built in way of doing this. You may need to write your own custom item in C++ and expose this to the QML context. It should be relatively simple to do.

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • B Offline
          B Offline
          buaacss
          wrote on last edited by
          #4

          I want to display some part of a image, and I guess the only way to do it is pointed out by ZapB~ Thank u for replying!

          [quote author="task_struct" date="1317632528"]Can you explain a bit more? You want to display a piture in some position on the screen or you want to display some part of image?

          Taka a look at "Image.fillMode":http://doc.qt.nokia.com/4.7-snapshot/qml-image.html#fillMode-prop[/quote]

          1 Reply Last reply
          0
          • B Offline
            B Offline
            buaacss
            wrote on last edited by
            #5

            hi guys, I solved this in this way!
            @
            Rectangle{
            id: login
            clip: true
            width: 80
            height: 25
            Image {
            id: loginButton
            x: 80
            y: 0
            source: "./image/Login_btn_login.png"
            }
            }
            @
            Put an image in a rectangle change x and y of the image, until get the right part of the image! Cheers!

            Edit: Be sure and wrap code in @ tags; mlong

            1 Reply Last reply
            0
            • T Offline
              T Offline
              task_struct
              wrote on last edited by
              #6

              I`ve just wrote similar example :)

              "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

              • Linu...
              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbrasser
                wrote on last edited by
                #7

                Hi,

                Glad you found a solution for this. Note that using an Item to do the clip, rather than a Rectangle, may be slightly more efficient (a Rectangle will try to paint itself, while an Item won't).

                Regards,
                Michael

                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