In my application I have rectangle which I can resize (manually implemented mouse events for resizing). My problem is that I can resize my rectangle in any size. How can I implement function which forbids to resize under 100x100 pixels. In other words I want function which sets minimum size for rectangle so user can't resize that rectangle under 100x100 pixels. If needed I will provide parts of mine code, but for now I need idea or pseudo code.
Asked
Active
Viewed 488 times
-1
-
please read document about sizeHint – camino Apr 03 '13 at 21:34
-
here is a nice article http://stackoverflow.com/questions/4553304/help-needed-to-understand-form-layout-mechanisms-in-qt – camino Apr 03 '13 at 21:36
-
Thanks but rectangle doesn't have sizeHint and I resize rectangle by mouse, it's size is not affected by size of other components or mainwindow – Alen Apr 03 '13 at 21:47
-
how about resizeEvent? – camino Apr 04 '13 at 02:09
-
add the size constraint in the mouseevent, where you are calculating the rectangle size. – UmNyobe Apr 04 '13 at 08:08
1 Answers
0
If you have already written the code, which resizes your rectangle, all you need to add is something like this:
QRect r = oldRect();
switch (border)
{
case Left:
r.setLeft(newLeftPos());
if (r.width() < minimumWidth())
r.setLeft(r.right() - minimumWidth());
break;
...
}
draw(r);

Amartel
- 4,248
- 2
- 15
- 21
-
-
Exactly. The same code should be written for all other sides (and corners, if you want to) of the rectangle. – Amartel Apr 04 '13 at 15:08
-