Results 1 to 12 of 12

Thread: mouseDoubleClickEvent on QGraphicsItem's

  1. #1
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default mouseDoubleClickEvent on QGraphicsItem's

    How can I check for a double-click on my items?

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    Quote Originally Posted by been_1990 View Post
    How can I check for a double-click on my items?
    What items?

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    bool QGraphicsItem::sceneEvent ( QEvent * event )

    event is QEvent::GraphicsSceneMouseDoubleClick
    "Behind every great fortune lies a crime" - Balzac

  4. #4
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    How exactly do I use that?

  5. #5
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    why cant you re-impliment "void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event ) ".

    To use sceneEvent(), u should first register the item for which u need all the events and filter the events.
    To register you can use "void installSceneEventFilter ( QGraphicsItem * filterItem )".
    and override bool sceneEvent ( QEvent * event ) and filter the events which you need..

  6. #6
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    wow..... maybe an example? Thats a litle beyond me.

  7. #7
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    see the previous to last post of this thread
    http://www.qtcentre.org/forum/f-newb...eys-22921.html
    "Behind every great fortune lies a crime" - Balzac

  8. #8
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    Qt Code:
    1. bool RecRepView:: eventFilter(QObject *ob, QEvent *e)
    2. {
    3. if(e->type() == QEvent::KeyPress){
    4. printf("is it coming inside event..\n");
    5. const QKeyEvent *ke = static_cast<QKeyEvent *>(e);
    6. if(ke->key()==Qt::Key_F1){
    7. qApp->quit();
    8. printf("Logout buttin clicked..\n");
    9. }
    10. return true;
    11. }
    12. return QWidget::eventFilter(ob, e);
    13. }
    To copy to clipboard, switch view to plain text mode 

    Ok. So just by having this function it gets called automatically every time QObject *ob receives an event?
    Or do I still need signals/slots?

  9. #9
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    Qt Code:
    1. e->type() == QEvent::KeyPress
    To copy to clipboard, switch view to plain text mode 
    instead u use
    Qt Code:
    1. e->type() == QEvent::GraphicsSceneMouseDoubleClick
    To copy to clipboard, switch view to plain text mode 

    and inside the condition u can do any thing .. display a alert message dialog or emit a signal or return a statement ..etc ..
    "Behind every great fortune lies a crime" - Balzac

  10. #10
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    so I'll use the function like ? :
    Qt Code:
    1. eventFilter(myGraphicsItem, QEvent *e);
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    Quote Originally Posted by been_1990 View Post
    so I'll use the function like ? :
    Qt Code:
    1. eventFilter(myGraphicsItem, QEvent *e);
    To copy to clipboard, switch view to plain text mode 
    why u have to use function like eventFilter(myGraphicsItem, QEvent *e) ...!

    its a virtual function reimplement the virtual function in your QGraphicsView class and install this event filter in your QGraphicsScene() of the view ..

    see the link
    http://doc.trolltech.com/4.3/eventsa...#event-filters
    "Behind every great fortune lies a crime" - Balzac

  12. #12
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: mouseDoubleClickEvent on QGraphicsItem's

    Okay. Now my mind cleared up. Thanks for the help, my problem is solved.Tx.

Similar Threads

  1. Copy and Paste of QGraphicsItems in a Scene
    By subash in forum Qt Programming
    Replies: 6
    Last Post: 6th July 2011, 15:15
  2. qt 4.4 Issue with too many QGraphicsItems
    By spawn9997 in forum Qt Programming
    Replies: 6
    Last Post: 2nd September 2009, 15:56
  3. How to put scaled QGraphicsItems next to eachother
    By profoX in forum Qt Programming
    Replies: 6
    Last Post: 3rd June 2008, 07:44
  4. Replies: 3
    Last Post: 11th April 2008, 12:25
  5. Problems with QGraphicsItems
    By JonathanForQT4 in forum Qt Programming
    Replies: 5
    Last Post: 26th April 2007, 08:25

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.