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. Adding outline around multiple rectangles
Forum Updated to NodeBB v4.3 + New Features

Adding outline around multiple rectangles

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 297 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.
  • P Offline
    P Offline
    pets
    wrote on last edited by
    #1

    Hello,

    I paint some easy figures using multiple rectangles, for instance: sample.png

    Is it possible to create a border (outline) around the figure's border using Qt effects?

    Regards,

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

      This is using DropShadow (part of QtGraphicalEffects 1.0) , try the following;

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtGraphicalEffects 1.0
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Column {
              id: shape
              x: 160; y: 120
      
              Rectangle {
                  id: top
                  width: 300; height: 50
                  color: "black"
              }
              Rectangle {
                  id: mid
                  x: 100
                  width: 50; height: 200
                  color: "black"
              }
              Rectangle {
                  id: bot
                  x: 100; y: 200
                  width: 200; height: 50
                  color: "black"
              }
          }
          DropShadow {
              source: shape
              anchors.fill: shape
              spread: 0.9
              color: "red"
          }
      }
      

      Capture.JPG

      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
      3
      • P Offline
        P Offline
        pets
        wrote on last edited by
        #3

        Thanks! I did almost the same but used anchors instead of fixed positioning which did not work. After changing all to fixed positions it works fine.

        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