hi, i have to catch keyPressEvent(QKeyEvent* f_event) on item (derived from QGraphicsObject), i am not able to get the event in item, instead it is going into infinite loop in scene itself.
below is the code, thanks in advance.
Qt Code:
//scene { if(item && item->isSelected()) { switch (f_event->key()) { case Qt::Key_Up: case Qt::Key_Down: case Qt::Key_Left: case Qt::Key_Right: Item->setFocus(); //i have set item is focusable flag in item constructor. QGraphicsScene::keyPressEvent(f_event); //here its going back to the MyScene::keyPressEvent(QKeyEvent* f_event)again & into infinite loop, Item::keyPressEvent(QKeyEvent* f_event) is not calling at all break; default: } } //item class Item : public QGraphicsObject { Q_OBJECT /////////////////....../////// protected: Q_DISABLE_COPY(Item); }; { QGraphicsObject::keyPressEvent(f_event); //qDebug()<<"keyPressEvent"; f_event->accept(); }To copy to clipboard, switch view to plain text mode
Bookmarks