Results 1 to 2 of 2

Thread: Key event not receiving from QGraphicsRectItem

  1. #1

    Default Key event not receiving from QGraphicsRectItem

    Hi i am new to Qt,

    i have added a rect of QGraphicsRectItem and added a member function
    void MyRect::keyPressEvent(QKeyEvent *event)
    {
    qDebug() << "MyRect knows that you pressed a key";
    }

    I have set the flags as well like below
    rect->setFlag(QGraphicsItem::ItemIsFocusable,true);
    rect->setFocus();

    but still when i am clicking on the rectangle, i am not able to see the o/p on console log.
    please can any help me out.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,190
    Thanks
    36
    Thanked 1,489 Times in 1,441 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Key event not receiving from QGraphicsRectItem

    Is the QGraphicsView or its viewport() the application's focusWidget() ?

    Cheers,
    _

Similar Threads

  1. QGraphicsRectItem not receiving hoverevents
    By hellozee in forum Newbie
    Replies: 0
    Last Post: 18th July 2018, 12:05
  2. Qt/MFC Event Loop - stop MFC receiving event?
    By Kaylx in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2012, 19:57
  3. Receiving application foreground event
    By kokilakr in forum Qt Programming
    Replies: 0
    Last Post: 24th June 2010, 12:31
  4. Receiving COM event with QAxObject
    By ronald in forum Qt Programming
    Replies: 0
    Last Post: 7th January 2010, 21:38
  5. function to stop receiving event
    By babu198649 in forum Qt Programming
    Replies: 11
    Last Post: 19th November 2007, 09:45

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.