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. Cut an inner region in a rectangle
QtWS25 Last Chance

Cut an inner region in a rectangle

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 3 Posters 6.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.
  • I Offline
    I Offline
    ixSci
    wrote on last edited by
    #1

    Hello all,

    I'm new in a developing with QML language and I'm stuck with a problem: I've 2 rectangles one inside another and I want the inner rectangle "cuts" the region it occupied from the outer rectangle. I need it because I'm using the outer rect as the border for the inner one, but inner color has an alpha channel part and as a result I have some undesirable color of the inner rect. Is there a way to accomplish the task?
    I doesn't use a border property because it overlaps with a rect inner space.

    Thank in advance!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fcrochik
      wrote on last edited by
      #2

      Let me see if I understood you correctly: you want to make a hole on the larger rectangle by adding a "transparent" on top of it?

      Your best bet is to create 4 small rectangles (top,left,right,bottom) to create your border around the "central/inner" rectangle.

      Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ixSci
        wrote on last edited by
        #3

        No, I don't wont to make holes :) But my inner rect is partly transparent and its color is blending with outer(border rect). I don't want any blending here.
        It would be exactly what I need if there were bitwise operations on images\rectangles, but I found none.
        fcrochik, your solution is obviously reasonable but it is rather the workaround. If there is no other way then I'll use it, but maybe there is?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcrochik
          wrote on last edited by
          #4

          ixSci:

          If your inner rectangle is transparent it has to blend to something. If you want to blend to the background (not the outer rectangle) than you actually "want" a hole on the outer rectangle so you can "see trough".

          I don't think there is another way.

          Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

          1 Reply Last reply
          0
          • I Offline
            I Offline
            ixSci
            wrote on last edited by
            #5

            Ok, you understood me right.

            I don’t think there is another way.
            I'm afraid you are right but maybe Trolls will say anything about this. Because absence of bitwise operations substantially reduce capabilities for working with figures and images.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbrasser
              wrote on last edited by
              #6

              Hi,

              I can confirm there is no built-in way to accomplish this -- you'll need to write your own item in QML (as suggested above; you might also want to experiment with BorderImage) or C++.

              Regards,
              Michael

              1 Reply Last reply
              0
              • I Offline
                I Offline
                ixSci
                wrote on last edited by
                #7

                Thank you both for answers.
                mbrasser, are there any plans for adding bitwise operations into QML?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mbrasser
                  wrote on last edited by
                  #8

                  [quote author="ixSci" date="1292565051"]bitwise operations into QML?[/quote]
                  Could you give any more details about what you are looking for? Javascript (and thus QML) provides bitwise operators, but QML does not give access to raw pixel data for images, which might be what you are missing.

                  With the QML scene graph project, the focus is shifting to GL shaders for graphical manipulation of items -- would something like that be helpful to you in this case?

                  Regards,
                  Michael

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    ixSci
                    wrote on last edited by
                    #9

                    [quote author="mbrasser" date="1292566775"]
                    With the QML scene graph project, the focus is shifting to GL shaders for graphical manipulation of items -- would something like that be helpful to you in this case?
                    [/quote]

                    I'd like to see something like Rectangle{ overlapMode: intersect\unite\exclude etc.} but maybe I'm missing something. It happens very often when studying new technology but continue to keep in mind an older one.
                    Now I'm going to use a four-part border and when I have more thorough knowledge in QML perhaps I'll offer some 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 Extensions
                    • Unsolved