Results 1 to 2 of 2

Thread: keyReleaseEvent not called

  1. #1
    Join Date
    Apr 2015
    Qt products
    MacOS X

    Default keyReleaseEvent not called

    I have a custom QGraphicsTextItem with a keyReleaseEvent, but this event is never called when I release a key.
    This is the way I create my custom QGraphicsItem:
    Qt Code:
    1. CustomQGraphicsTextItemClass *oneTextNode=new CustomQGraphicsTextItemClass();
    2. scene()->addItem(oneTextNode);
    3. oneTextNode->setFlags(QGraphicsItem::ItemIsFocusable);
    4. oneTextNode->setFocus();
    To copy to clipboard, switch view to plain text mode 

    and my custom QGraphicsItem constructor has this command:
    Qt Code:
    1. setTextInteractionFlags(Qt::TextEditorInteraction);
    To copy to clipboard, switch view to plain text mode 

    The release code is the following:
    Qt Code:
    1. void CustomQGraphicsTextItemClass::keyReleaseEvent(QKeyEvent *e)
    2. {
    3. MGlobal::displayInfo(MQtUtil::toMString(QString().sprintf("Release !!!!!!!")));
    4. }
    To copy to clipboard, switch view to plain text mode 

    The Release function is never called. There is a keyPressEvent too, but this one gets properly called.

    Thanks for your help.

  2. #2
    Join Date
    Jan 2006
    Thanked 1,005 Times in 913 Posts
    Qt products
    Unix/X11 Windows Symbian S60
    Wiki edits

    Default Re: keyReleaseEvent not called

    Can't test it right now, but when I remember right, you have to grab the keyboard first to receive key events: QGraphicsItem::grabKeyboard().

Similar Threads

  1. keyReleaseEvent problem
    By RENOLD in forum Qt Programming
    Replies: 2
    Last Post: 15th February 2012, 14:14
  2. Destructor not being called
    By vieraci in forum Qt Programming
    Replies: 12
    Last Post: 25th January 2012, 16:06
  3. No paintEvent is called
    By HeReSY in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2011, 17:11
  4. Why Qt is called Qt?
    By nifei in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2009, 08:40
  5. Slot gets called twice
    By greatgatsby in forum Newbie
    Replies: 7
    Last Post: 20th August 2009, 16:11

Tags for this Thread


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.