December 16, 2010

ixSci ixSci
Lab Rat
172 posts

Cut an inner region in a rectangle

 

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!

8 replies

December 16, 2010

fcrochik fcrochik
Lab Rat
447 posts

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.

 Signature 

Certified Specialist & Qt Ambassador Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop… Qt everywhere!

December 16, 2010

ixSci ixSci
Lab Rat
172 posts

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?

December 16, 2010

fcrochik fcrochik
Lab Rat
447 posts

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.

 Signature 

Certified Specialist & Qt Ambassador Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop… Qt everywhere!

December 16, 2010

ixSci ixSci
Lab Rat
172 posts

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.

December 17, 2010

mbrasser mbrasser
Lab Rat
452 posts

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

December 17, 2010

ixSci ixSci
Lab Rat
172 posts

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

December 17, 2010

mbrasser mbrasser
Lab Rat
452 posts

ixSci wrote:
bitwise operations into QML?

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

December 17, 2010

ixSci ixSci
Lab Rat
172 posts
mbrasser wrote:
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?

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

 
  ‹‹ File Handling      [solved] How can I make something like Qt.createComponent(Rectangle) ? ››

You must log in to post a reply. Not a member yet? Register here!