1

I want to create a resizeable selection tool to select a part of an image with the mouse. I want to accomplish this with QT, i have a working QRubberBand to create a basic selection.

Next step is to make that selection resizeable with the mouse. So if you click&drag a corner the size changes accordingly and if you click&drag inside the selection it should move the selection.

now my idea is subclassing QRubberBand and overriding the paintEvent method to paint a big dot on every corner and perform the mouseevents on those dots. But i was wondering if anyone has a smarter/better way of doing this?

i'd like to hear some ideas on this. thanks in advance.

user458753
  • 147
  • 2
  • 3
  • 15
  • Did you ever implement this? I am looking to do exactly the same thing. – David Doria Nov 15 '11 at 16:41
  • no i never did because the project got pushed back but i will be working on it this week. Did you make this? if so any tips? – user458753 Nov 21 '11 at 13:41
  • I almost have it working. I'll post a link when it is done (later this week). – David Doria Nov 21 '11 at 18:36
  • I have the right handle working properly. The when you collapse the rectangle with the left handle, the right edge moves, which is not what I want to happen (obviously). Any clues where that is going wrong? Anyone interesting in working on this please send me your github username: https://github.com/daviddoria/QtHandleItem – David Doria Nov 21 '11 at 21:43

2 Answers2

0

I just implemented a general framework for arbitrary interactive overlay graphics for my Qt image and vector viewer. Please see the branch Lasso in https://github.com/dov/Qviv/tree/Lasso/Lasso . You can compile it with scons and then run testLasso to test it. Currently the test implements a movable semitransparent caliper, but you can easily change it to any graphics you desire. Note that the Lasso sub directory is currently completely independent of the rest of the Qviv project.

Dov Grobgeld
  • 4,783
  • 1
  • 25
  • 36
0

I did something similar before. I used QGraphicsView instead of QWidget which made the development much easier. I used QGraphicsItem as the "rubber band". QGraphicsView already handles a lot of user interaction so I didn't have to bother with reimplementing QWidget::mouseMove() events, etc. Plus the performance was much faster than on QWidget because of QGraphicsView optimizations.

Hope this helps

Barbaris
  • 1,256
  • 7
  • 7