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. Round the Corner of Map
Forum Updated to NodeBB v4.3 + New Features

Round the Corner of Map

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 3 Posters 1.6k 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.
  • T Offline
    T Offline
    tacdin
    wrote on last edited by
    #1

    Hi, I need to use map for an application. It will be on a rectangle with a radius. I want to round the corners of the map the same way I round the corners of the rectangle. The QML Map type does not allow this. How can I do this? Thank you for your help.![alt metni]

    rounded map.drawio.png

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      Try OpacityMask as an enabled layer.

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tacdin
        wrote on last edited by
        #3

        I'm trying but I have no idea how to implement it :( @Markkyboy

        1 Reply Last reply
        0
        • MarkkyboyM Offline
          MarkkyboyM Offline
          Markkyboy
          wrote on last edited by Markkyboy
          #4

          Have you looked at the docs?, https://doc.qt.io/qt-5/qml-qtgraphicaleffects-opacitymask.html, albeit the docs don't mention 'layer' which may not be required. Without seeing your code, it is guess work on my part. Also, see here https://doc.qt.io/qt-5/qml-qtquick-item.html for information on 'layer.enabled'

          EDIT: here's some code for you try;

          import QtQuick 2.12
          import QtQuick.Window 2.12
          import QtGraphicalEffects 1.0
          
          Window {
              width: 640
              height: 480
              visible: true
              color: "lightgrey"
              title: qsTr("tacdin - rounded corners")
          
              Rectangle {
                  id: background
                  width: 350
                  height: 150
                  radius: 20
                  color: "#fef2cc"
                  border {
                      width: 1
                      color: "black"
                  }
                  anchors.centerIn: parent
              }
              Image {
                  id: map
                  source: "map.jpg"
                  anchors.centerIn: parent
                  layer.enabled: true
                  layer.effect: OpacityMask {
                      maskSource: Rectangle {
                          width: background.width
                          height: background.height
                          radius: background.radius
                      }
                  }
              }
          }
          

          tacdin.JPG

          Don't just sit there standing around, pick up a shovel and sweep up!

          I live by the sea, not in it.

          T 2 Replies Last reply
          1
          • MarkkyboyM Markkyboy

            Have you looked at the docs?, https://doc.qt.io/qt-5/qml-qtgraphicaleffects-opacitymask.html, albeit the docs don't mention 'layer' which may not be required. Without seeing your code, it is guess work on my part. Also, see here https://doc.qt.io/qt-5/qml-qtquick-item.html for information on 'layer.enabled'

            EDIT: here's some code for you try;

            import QtQuick 2.12
            import QtQuick.Window 2.12
            import QtGraphicalEffects 1.0
            
            Window {
                width: 640
                height: 480
                visible: true
                color: "lightgrey"
                title: qsTr("tacdin - rounded corners")
            
                Rectangle {
                    id: background
                    width: 350
                    height: 150
                    radius: 20
                    color: "#fef2cc"
                    border {
                        width: 1
                        color: "black"
                    }
                    anchors.centerIn: parent
                }
                Image {
                    id: map
                    source: "map.jpg"
                    anchors.centerIn: parent
                    layer.enabled: true
                    layer.effect: OpacityMask {
                        maskSource: Rectangle {
                            width: background.width
                            height: background.height
                            radius: background.radius
                        }
                    }
                }
            }
            

            tacdin.JPG

            T Offline
            T Offline
            tacdin
            wrote on last edited by
            #5

            @Markkyboy The code worked! thank you very much. :) Kind regards

            Pablo J. RoginaP 1 Reply Last reply
            0
            • T tacdin

              @Markkyboy The code worked! thank you very much. :) Kind regards

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @tacdin said in Round the Corner of Map:

              The code worked!

              great, so please don't forget to mark your post as solved.

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • MarkkyboyM Markkyboy

                Have you looked at the docs?, https://doc.qt.io/qt-5/qml-qtgraphicaleffects-opacitymask.html, albeit the docs don't mention 'layer' which may not be required. Without seeing your code, it is guess work on my part. Also, see here https://doc.qt.io/qt-5/qml-qtquick-item.html for information on 'layer.enabled'

                EDIT: here's some code for you try;

                import QtQuick 2.12
                import QtQuick.Window 2.12
                import QtGraphicalEffects 1.0
                
                Window {
                    width: 640
                    height: 480
                    visible: true
                    color: "lightgrey"
                    title: qsTr("tacdin - rounded corners")
                
                    Rectangle {
                        id: background
                        width: 350
                        height: 150
                        radius: 20
                        color: "#fef2cc"
                        border {
                            width: 1
                            color: "black"
                        }
                        anchors.centerIn: parent
                    }
                    Image {
                        id: map
                        source: "map.jpg"
                        anchors.centerIn: parent
                        layer.enabled: true
                        layer.effect: OpacityMask {
                            maskSource: Rectangle {
                                width: background.width
                                height: background.height
                                radius: background.radius
                            }
                        }
                    }
                }
                

                tacdin.JPG

                T Offline
                T Offline
                tacdin
                wrote on last edited by
                #7

                @Markkyboy Another problem is this. As you can see in the figure, there is a rectangle on the map. When I slide the slider inside the rectangle, the map also slides! (pan,flick). What should be done to prevent this?
                rounded map-with-slider.png

                MarkkyboyM 1 Reply Last reply
                0
                • T tacdin

                  @Markkyboy Another problem is this. As you can see in the figure, there is a rectangle on the map. When I slide the slider inside the rectangle, the map also slides! (pan,flick). What should be done to prevent this?
                  rounded map-with-slider.png

                  MarkkyboyM Offline
                  MarkkyboyM Offline
                  Markkyboy
                  wrote on last edited by
                  #8

                  @tacdin - no idea, sorry, never used slider in a project before.

                  Don't just sit there standing around, pick up a shovel and sweep up!

                  I live by the sea, not in it.

                  1 Reply Last reply
                  0
                  • MarkkyboyM Markkyboy referenced this topic on

                  • Login

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