PDA

View Full Version : Resize image with mouse



NortT
1st May 2011, 16:12
Hi all!
I have a question.. QTextEdit contains several image. How to click on any image, hold from a corner of it, and resize them?
I found topic (http://stackoverflow.com/questions/3720502/how-to-resize-an-image-in-a-qtextedit), but this solution does not suit me, because it uses dialog window, and I want change size with mouse.
P.S. Sorry for my bad english :)

high_flyer
2nd May 2011, 16:52
Well, if the implementation in the link you posted works, then you basically have all you need.
To have what you want you will have to:
1. catch a mouse press event, see if its on your image border, to be able to start the resize.
2. Once you have solved 1, you will be calling the code from the link you posted for each movement (mouseMoveEvent()) (and feed the new image size based on your mouse position instead of the dialog used in the link), which is basically setting the image again with its new size, causing QTextEdit to adjust all its contents accordingly, which can be quite slow.You might want to not update the contents of your QTextEdit while resizing (maybe just displaying a rubber band) and only apply one resize on mouseReleaseEvent().

Bareos
16th November 2011, 12:26
Hi.
I'm on the same Problem and informations are very rare. I started a Thread in the Qt Developer Network. Somebody posted a nice idea to get the Position and Size of Images in a QTextEdit. There are still some problems but maybe it leads in the right direction.

http://developer.qt.nokia.com/forums/viewthread/11509/

Maybe it helps