Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] How to make rect-like figure?
Qt 6.12 LTS is out! See what's new in the release blog

[solved] How to make rect-like figure?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 4 Posters 1.7k Views 1 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.
  • M Offline
    M Offline
    morte
    wrote on last edited by
    #1

    How i can make figure like that:
    !http://s24.postimg.org/m8yvejw01/rect.png(image)!
    (Two merged rectangles without border on intersection line)?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,
      IMO the best way would be to use QQuickPaintedItem and then draw the shape using QPainterPath.

      157

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kaivolde
        wrote on last edited by
        #3

        Adding to the previous post: You have to write a C++ extension for QML. The process is described here:
        http://qt-project.org/doc/qt-5/qml-extending-tutorial-index.html

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Maybe I didn't understand the question correctly, but this code produces the image shown. I just hacked this together, might be better to use explicit z ordering but this works.

          @ Rectangle{
          x: 10
          y:10
          width: 50; height: width
          color:"white"
          border.width: 4
          border.color: "black"
          }

          Rectangle{
              x: 10
              y:30
              width: 200; height: 100
              color:"white"
              border.width: 4
              border.color: "black"
          }
          Rectangle{
              x: 14
              y:30
              width: 42; height: 10
              color:"white"
              border.width: 1
              border.color: "white"
          }
          

          @
          !https://dl.dropboxusercontent.com/u/41770120/RectLike.png(result of code)!

          1 Reply Last reply
          0
          • M Offline
            M Offline
            morte
            wrote on last edited by
            #5

            Thanks for your suggestions!

            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
            • Unsolved