Results 1 to 3 of 3

Thread: QGraphicsScene and Extended Selection of items

  1. #1
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default QGraphicsScene and Extended Selection of items

    I'm stuck with the following problem :

    I have a scene with several QGraphicsItems-derived instances. I make a first selection, then I want to extend it using CTRL-key and rubber band. The problem is that QGraphicsView does not seem to support extended selection due to following code :

    in qgraphicsview.cpp :

    Qt Code:
    1. void QGraphicsView::mousePressEvent(QMouseEvent *event)
    2. {
    3.  
    4. // ...
    5.  
    6. #ifndef QT_NO_RUBBERBAND
    7. if (d->dragMode == QGraphicsView::RubberBandDrag && !d->rubberBanding) {
    8. if (d->sceneInteractionAllowed) {
    9. // Rubberbanding is only allowed in interactive mode.
    10. event->accept();
    11. d->rubberBanding = true;
    12. d->rubberBandRect = QRect();
    13. if (d->scene) {
    14. // Initiating a rubber band always clears the selection.
    15. d->scene->clearSelection();
    16. }
    17. }
    18. } else
    19. #endif
    20.  
    21. // ...
    22. }
    To copy to clipboard, switch view to plain text mode 

    As you see, "Initiating a rubber band always clears the selection". So I tried to overload my scene's clearSelection() method to have my word on it, but unfortunately it's not a virtual method and thus it's not called.

    I'd prefer a check at scene's level, not at item's level (indeed, i could check for QApplication::keyboardModifiers() in the itemChange() method of each item, but it's kinda intrusive)

    Anybody faced the same problem ?

    Thanks in advance for your answers

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and Extended Selection of items

    but u can override mousePressEvent ,,, cant you ?

  3. #3
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and Extended Selection of items

    Do you mean i should copy the contents of QGraphicsView::mousePressEvent() in my custom View ?
    I'm afraid I can't access the private part of the view, the one obtained using Q_D()... And thus not able to initialize rubber band

    I will try and let you know, thank you for your idea

Similar Threads

  1. Replies: 0
    Last Post: 20th December 2009, 20:54
  2. QGraphicsScene and multiple selection
    By Bill in forum Newbie
    Replies: 1
    Last Post: 4th August 2009, 15:19
  3. Custom items selection in qgraphicsscene
    By yonnak in forum Qt Programming
    Replies: 7
    Last Post: 28th March 2009, 11:32
  4. Adding items to a QGraphicsScene's selection list?
    By mooreaa in forum Qt Programming
    Replies: 2
    Last Post: 1st July 2008, 20:01
  5. extended selection in q3listview
    By sreedhar in forum Qt Programming
    Replies: 7
    Last Post: 13th November 2006, 09:03

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.