Results 1 to 2 of 2

Thread: Mimic behaviour across QGraphicsViews

  1. #1
    Join Date
    Jun 2014
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Mimic behaviour across QGraphicsViews

    I have two subclassed QGraphicsViews in my application. When the mouse is dragged in the one, I want to mimic this drag in the other QGraphicsView. At first I thought I could just catch the QMouseEvent in the active view and pass it to the other using a signal/slot combination, but although I can confirm that the event is received, no drag takes place. Here is some code to illustrate what I mean:

    Qt Code:
    1. void MyQGraphicsView::mousemoveEvent(QMouseEvent* event) {
    2. // here some other stuff happens
    3. emit signalFakeMouseMoveEvent(event);
    4. }
    5.  
    6. // connected to the signalFakeMouseMoveEvent of the other MyQGraphicsView
    7. void MyQGraphicsView::slotFakeMouseMoveEvent(QMouseEvent* event) {
    8. QGraphicsView::mouseMoveEvent(event); // the correct event is received here
    9. }
    To copy to clipboard, switch view to plain text mode 

    I have confirmed that the correct QMouseEvent is received in the lower of the two snippets given above, but only the active view is dragged.

    I am wondering if a drag event in QGraphicsView is implemented in more than just QGraphicsView::mouseMoveEvent. Can anyone shed any light on how to achieve this? Thanks!

    Alternative:
    The alternative would be for me manually to compute the distance dragged, and send this to the other view, but this comes with all kinds of headaches such as dealing with the case when a view is dragged more than allowed. I would rather avoid this.

  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: Mimic behaviour across QGraphicsViews

    You could try connecting each view's scrollbars with those of the other view.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 21st February 2012, 23:40
  2. One QGraphicsScene in two QGraphicsViews
    By klaviaturist in forum Qt Programming
    Replies: 9
    Last Post: 30th March 2011, 09:37
  3. how to mimic this functionality with Qt
    By javimoya in forum Qt Programming
    Replies: 9
    Last Post: 28th December 2010, 04:51
  4. Replies: 3
    Last Post: 2nd August 2010, 10:12
  5. Scrolling 2 QGraphicsViews with 1 scrollbar
    By dentist in forum Newbie
    Replies: 2
    Last Post: 14th April 2010, 02:12

Tags for this Thread

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.