Results 1 to 3 of 3

Thread: Resize image with mouse

  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Resize image with mouse

    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, 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
    Last edited by NortT; 1st May 2011 at 16:18.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Resize image with mouse

    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().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    NortT (4th May 2011)

  4. #3
    Join Date
    Nov 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Resize image with mouse

    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

Similar Threads

  1. Replies: 6
    Last Post: 7th February 2012, 02:03
  2. Resize Image
    By kamlesh.sangani in forum General Programming
    Replies: 5
    Last Post: 15th January 2011, 11:51
  3. Replies: 1
    Last Post: 13th August 2010, 06:33
  4. Resize QLayout w/ Mouse...or, a QWidget similar to QDockWidget
    By kiss-o-matic in forum Qt Programming
    Replies: 2
    Last Post: 24th December 2009, 10:05
  5. Replies: 3
    Last Post: 3rd September 2008, 16:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.