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. Scaling a BorderImage source before repeating
QtWS25 Last Chance

Scaling a BorderImage source before repeating

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
borderimageqmlscaling
4 Posts 2 Posters 1.6k 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.
  • P Offline
    P Offline
    Phrogz
    wrote on 24 May 2017, 16:42 last edited by Phrogz
    #1

    I want to use a border image (two, even) for a progress bar that looks like this:
    Bar made of chevrons

    The bar can be arbitrary width. As it gets longer, the number of chevrons (arrow thingies) in the middle should repeat. No problem, we have horizontalTileMode:BorderImage.Round on our side.

    The bar can be arbitrary height. As it gets taller, the height of the chevrons should scale up. No problem, we set the border.top:0; border.bottom:0; verticalTileMode:BorderImage.Stretch and voila, it stretches.

    However...the aspect ratio of the chevrons should not change. They should always be 45 degree angles. The combination of the above two tile modes makes for too-tall or too-short chevrons if the height of the bar is not exactly the same as the height of the original image source.

    squished chevrons
    stretched chevrons

    What I really want to do is scale the source for the border image based on the height of the bar, and then use that post-scaled image as a border image. Is there any way to do this? Can I somehow create an Image, stretch that, and then use it as an image source for the BorderImage?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jagh
      wrote on 24 May 2017, 17:18 last edited by
      #2

      You can subclass QQuickImageProvider to source appropriately scaled images... However, this must be done on C++ side.

      P 1 Reply Last reply 24 May 2017, 17:26
      0
      • J Jagh
        24 May 2017, 17:18

        You can subclass QQuickImageProvider to source appropriately scaled images... However, this must be done on C++ side.

        P Offline
        P Offline
        Phrogz
        wrote on 24 May 2017, 17:26 last edited by
        #3

        @Jagh said in Scaling a BorderImage source before repeating:

        You can subclass QQuickImageProvider to source appropriately scaled images... However, this must be done on C++ side.

        Thanks for this. I'd hoped to keep C++ out of this, but this smells doable. What would the usage of this look like in QML for the BorderImage source?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jagh
          wrote on 24 May 2017, 18:09 last edited by
          #4

          In C++ you register your image provider by providing a new resource prefix (say you chose "myimage") then in QML it will look like this:

          source: "myimage://myborderImage"
          

          Read Qt doc about QQuickImageProvider class, there is an example of how to use it

          1 Reply Last reply
          2

          3/4

          24 May 2017, 17:26

          • Login

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