Results 1 to 3 of 3

Thread: Selection area on image

  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Platforms
    Unix/X11

    Arrow Selection area on image

    Hi, All.

    I'm a total newbie here. Came from .NET development and having an urgent task on developing a Qt-application.

    Here's the task:
    I need to place an image on the form and provide user with ability to place a selection rectangle on the image, move it, resize etc. You know, like Adobe Photoshop's "Selection tool".
    Moving/resizing the selection rectangle should be keyboard-controlled, so I need something with strong API.

    Looks pretty easy, but what about Qt?
    Is there anything premade for my purposes?

    Any helpful links appreciated.

    Thanks.

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Selection area on image

    In a nutshell:

    Subclass QLabel and put your image onto it.
    Qt Code:
    1. QPixmap pixmap(fotoPath, "", 0);
    2. pictureWindow->setPixmap(pixmap);
    To copy to clipboard, switch view to plain text mode 

    Implement its paintEvent to draw a "rubber band".
    Have a look at QPainter to see how it's done.

    Implement its keyPressEvent to update() the widget when keypresses arrive.

    Life's good, with Qt

  3. #3
    Join Date
    Mar 2009
    Posts
    2
    Platforms
    Unix/X11

    Default Re: Selection area on image

    I've implemented that in another way:
    created a QGraphicsScene and loaded 2 QGraphicsItem there:
    one for the image
    second for the selection rect with QGraphicsItem::ItemIsMovable

    that actually is more satysfying my needs

    thanks for the reply

Similar Threads

  1. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  2. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  3. Replies: 3
    Last Post: 11th March 2007, 13:04
  4. displaying png image for a given area..
    By sar_van81 in forum Qt Programming
    Replies: 1
    Last Post: 17th January 2007, 13:56
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36

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.