Solved How to make the QGraphicsView re sizable by mouse?
-
I want to allow the user to be able to resize the graphics view by mouse.
something like the qt creator drawing window in the image below.I am searching for a while but can't find a way for doing it, so any help would be appreciated.
I am thinking that I need to put it in a container that allows this behavior, but still not sure if this is a valid thinking or not and if valid what kind of container could it be. -
hi
Maybe this be good starting point
http://www.davidwdrell.net/wordpress/?page_id=46 -
I already saw this link but it's working on adjusting the size of the item inside the view, not the view itself.
thanks a lot. -
Hi and welcome to devnet,
How are you handling that view within your application ?
-
Hi,
Thanks,
please illustrate more the meaning of "how I am handling it" if I got it wrong.I am creating something like a drawing canvas so the QGraphicsView is in a splitter.
to it's left a QTreeView in which I drag and drop items to the QGraphicsView and to it's right a QTreeView to show the properties of the items.
I need the user to be able to set the size of the QGraphicsView which is in the middle of the splitter and to be allowed only to work within that area.
it's nearly the same behavior as that in the QT creator
what I'm doing right now is that I Just put the QGraphicsView in the Splitter and I set the Scene rectangle to some constant. but for sure this far away from the behavior needed. -
Ah, I was too hasty.
Missed it was the actual QGraphicsView widget you wanted to resize.
This then :)
https://wiki.qt.io/Widget-moveable-and-resizeableAlternative use http://doc.qt.io/qt-5/qrubberband.html
and let user select area and then simply set the size directly.However, since a splitter is a layout, you will have to cheat and use
setMaximumSize or similar to make it accept resizing the view. -
I will try both solutions, thanks alot.
-
@Mohamed-Hatem
Which one worked best ? -
Well, I didn't try the second solution yet but the first solution worked like a charm, thanks alot.