Results 1 to 6 of 6

Thread: QGraphicsView general questions

  1. #1
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QGraphicsView general questions

    Hello I am trying to reset a QGraphicsView's orientation to the same orientation it had before applying zoom and scale functions on the graphics view. My initial solution was to reload the pixmap item that the graphics view contained, but obviously that won't work. my question is how can i set the orientation of the graphics view to its default orientation (its orientation upon loading the whole application)

    Off Topic Question : What does rubberbanding mean? I've read this in a lot of threads and still can't imagine what this does.

    Off Topic Question: Can Anyone here direct/point me to a very good example of how to subclass QGraphicsView in order for me to place markers (dots) in my QGraphicsView? I was thinking of markers like in the Affine Transformations example in the demos of Qt. I can't understand the hoverpoint mechanism for the Affine Transformations example.
    Image Analysis Development Framework Using Qt (IADFUQ)

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView general questions

    You have to change the mapping back to identity:

    Qt Code:
    1. QMatrix mapping = graphicsview->matrix();
    2. mapping.reset(); //back to identity
    3. graphicsview->setMatrix(mapping);
    To copy to clipboard, switch view to plain text mode 


    Regards

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

    sincnarf (23rd August 2007)

  4. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView general questions

    Off Topic Question : What does rubberbanding mean? I've read this in a lot of threads and still can't imagine what this does.
    A rubberband is a rectangle that appears when performing selections by dragging the mouse. Not only in graphics views but also in items views. It shows you the selection bounds.

    Off Topic Question: Can Anyone here direct/point me to a very good example of how to subclass QGraphicsView in order for me to place markers (dots) in my QGraphicsView? I was thinking of markers like in the Affine Transformations example in the demos of Qt. I can't understand the hoverpoint mechanism for the Affine Transformations example.
    No example, but subclassing the view and overriding drawForeground should solve the painting problem.
    For interaction, you could override mouseMove/Press events for the view and check for the dots coordinates and act accordingly.

    Regards

  5. The following user says thank you to marcel for this useful post:

    sincnarf (23rd August 2007)

  6. #4
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView general questions

    Quote Originally Posted by marcel View Post
    A rubberband is a rectangle that appears when performing selections by dragging the mouse. Not only in graphics views but also in items views. It shows you the selection bounds.
    Okay, is there a way to get the item's contents based on the rubberband that was set? I want to implement sort of cropping the item. because I've read in the QGraphicsItem that rubberbanding the item only causes the selection of the whole item.

    Quote Originally Posted by marcel View Post
    subclassing the view and overriding drawForeground should solve the painting problem. For interaction, you could override mouseMove/Press events for the view and check for the dots coordinates and act accordingly.
    would using graphics ellipse items instead be better? See my problem is i've already created a sub class for a QGraphicsPixmapItem and it overrides the mousePressEvent(QGraphicsSceneMouseEvent *event) . . . but how can I add this item to my graphicsScene?
    Image Analysis Development Framework Using Qt (IADFUQ)

  7. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView general questions

    Quote Originally Posted by sincnarf View Post
    Okay, is there a way to get the item's contents based on the rubberband that was set? I want to implement sort of cropping the item. because I've read in the QGraphicsItem that rubberbanding the item only causes the selection of the whole item.
    Since rubberband's geometry is defined by the first mouse press position and the current mouse position you only need to reimplement QGraphicsView::mousePressEvent() and QGraphicsView::mouseMoveEvent().I guess you are better of to implement your own rubberbanding mechanism. Otherwise you might need to look at QGraphicsItem::ItemSelectionChange
    By cropping do you mean image cropping or something similar ? If so an idea will be to draw a translucent pixmap in the foreground in the mouse events of graphics view instead of rubberband.

    would using graphics ellipse items instead be better? See my problem is i've already created a sub class for a QGraphicsPixmapItem and it overrides the mousePressEvent(QGraphicsSceneMouseEvent *event) . . . but how can I add this item to my graphicsScene?
    I didn't get you i think because its as simple as scene->addItem(pointer to your item);
    I also suggest the ellipseItem way since that makes code simple (at the cost of bit of performance).
    If you can explain what your app actually focuses on we might help you in a better way
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  8. #6
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView general questions

    Quote Originally Posted by Gopala Krishna View Post
    By cropping do you mean image cropping or something similar ? If so an idea will be to draw a translucent pixmap in the foreground in the mouse events of graphics view instead of rubberband.
    something similar. it's not actually cropping (sorry). From the QGraphicsItem, if I rubberband on the item, after releasing the mousebutton I need to :
    1. let the rubberband stay there. the rubberband is only destroyed when I drag the mouse again.
    2. on dragging and creation of rubber band, the contents of the rubberband must be initialized to an image. The QGraphicsItem need nod be changed. so ItemSelectionChange is not needed.

    Quote Originally Posted by Gopala Krishna View Post
    If you can explain what your app actually focuses on we might help you in a better way
    well, my app is just a general framework that manages user (image processing functions). I need to implement capturing specific regions of interest in an image (into a new QImage). Also , the ellipses must be assigned to a Hashmap (maybe).
    I am now also currently working on histograms for the image and other possible mechanisms that add to getting/setting image features... That's basically it.
    Image Analysis Development Framework Using Qt (IADFUQ)

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.