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. How to specify border only for one side of a rectangle
Forum Updated to NodeBB v4.3 + New Features

How to specify border only for one side of a rectangle

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 6 Posters 14.4k 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.
  • S Offline
    S Offline
    Sandhiya
    wrote on last edited by
    #1

    We have a rectangle ,want to give a border of 3 pix only on the right side of the rectangle with the color red.How to achieve this without using custom rectangle as border.

    J.HilkJ 1 Reply Last reply
    0
    • S Sandhiya

      We have a rectangle ,want to give a border of 3 pix only on the right side of the rectangle with the color red.How to achieve this without using custom rectangle as border.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Sandhiya

      you don't

      either use a canvas and paint the border like you want it or place a 2nd rectangle where the border should be, adjust it size and set the background color to the border color.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      S 1 Reply Last reply
      2
      • J.HilkJ J.Hilk

        @Sandhiya

        you don't

        either use a canvas and paint the border like you want it or place a 2nd rectangle where the border should be, adjust it size and set the background color to the border color.

        S Offline
        S Offline
        Sandhiya
        wrote on last edited by
        #3

        @J.Hilk Anything other than that?

        J.HilkJ J 2 Replies Last reply
        0
        • S Sandhiya

          @J.Hilk Anything other than that?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @Sandhiya
          make your own Item via QQuickItem - base class (c++) and define that behaviour in the paint function. But that's in my opinion why to much effort for such a simple task.

          I know of no other way besides those 3 I posted.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          S 1 Reply Last reply
          2
          • S Sandhiya

            @J.Hilk Anything other than that?

            J Offline
            J Offline
            JasmineSethi
            wrote on last edited by JasmineSethi
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @Sandhiya
              make your own Item via QQuickItem - base class (c++) and define that behaviour in the paint function. But that's in my opinion why to much effort for such a simple task.

              I know of no other way besides those 3 I posted.

              S Offline
              S Offline
              Sandhiya
              wrote on last edited by
              #6

              @J.Hilk Thanks for the help. Will try using any of the 3 approaches.

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vladstelmahovsky
                wrote on last edited by vladstelmahovsky
                #7

                cover with another rectangle

                1 Reply Last reply
                1
                • ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by
                  #8

                  @Sandhiya
                  you can use clip property

                   Item {
                          height: 100
                          width: 100
                          clip: true
                          anchors.centerIn: parent
                          Rectangle {
                              anchors.fill: parent
                              anchors.rightMargin: -border.width
                              anchors.topMargin:  -border.width
                              anchors.bottomMargin: -border.width
                              border.width: 3
                              border.color:"red"
                          }
                      }
                  
                  1 Reply Last reply
                  3
                  • G Offline
                    G Offline
                    GrahamLa
                    wrote on last edited by
                    #9

                    Hi
                    You may find this helpful

                    1 Reply Last reply
                    3

                    • Login

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