Results 1 to 6 of 6

Thread: How to Draw and resize Rectangle

  1. #1
    Join Date
    Oct 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default How to Draw and resize Rectangle

    hii...,
    i new to qt .i want to draw and resize rectangle using mouse events on Qimage which is in label

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to Draw and resize Rectangle

    You could use QRubberBand.

    Or derive a class from QLabel, implement mouse event handlers to get the values for the rect.
    Reimplement paintEvent() such that you first call the implementation of the base class and then paint your rect on top of it.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How to Draw and resize Rectangle

    thanks for reply earlier i used QRubberBand but it is not compatible to my application and using mouse events i draw rectangle with QPainter. but my problem is resizeing that rectangle

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to Draw and resize Rectangle

    Quote Originally Posted by ranjithreddykommareddy View Post
    using mouse events i draw rectangle with QPainter. but my problem is resizeing that rectangle
    The QRect API is usually pretty straight forward.
    How do you attempt to resize the rectangle?

    Cheers,
    _

  5. #5
    Join Date
    Oct 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How to Draw and resize Rectangle

    then how can i do that resizing part..?i want to bound the objects in image so i need resizing .

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to Draw and resize Rectangle

    I assume you have a member variable of type QRect.
    So resizing the rect means changing that member's values and then calling update().

    Cheers,
    _

Similar Threads

  1. How to draw a rectangle or line on an image
    By Shubham in forum Newbie
    Replies: 6
    Last Post: 18th February 2014, 08:17
  2. Draw rectangle on QImage
    By ^NyAw^ in forum Qt Programming
    Replies: 12
    Last Post: 25th January 2013, 13:33
  3. Replies: 2
    Last Post: 9th November 2012, 18:16
  4. How to draw a QPainter rectangle over Widgets
    By sureshdharmadurai in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2011, 11:17
  5. how to draw columns in QPainter's rectangle
    By jyoti in forum Qt Programming
    Replies: 1
    Last Post: 24th August 2007, 11:50

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.