Пример #1
0
void AbstractContent::keyPressEvent(QKeyEvent * event)
{
    // discard key events for unselectable items
    if (!(flags() & ItemIsSelectable)) {
        event->ignore();
        return;
    }
    event->accept();
    int step = (event->modifiers() & Qt::ShiftModifier) ? 50 : (event->modifiers() & Qt::ControlModifier ? 1 : 10);
    switch (event->key()) {
        // cursor keys: 10px, 50 if Shift pressed, 1 if Control pressed
        case Qt::Key_Left:      setPos(pos() - QPointF(step, 0));   break;
        case Qt::Key_Up:        setPos(pos() - QPointF(0, step));   break;
        case Qt::Key_Right:     setPos(pos() + QPointF(step, 0));   break;
        case Qt::Key_Down:      setPos(pos() + QPointF(0, step));   break;

        // deletion
        case Qt::Key_Delete: emit requestRemoval(); break;

        // editing
        case Qt::Key_Return: emit requestEditing(); break;

        // ignore unhandled key
        default: event->ignore();
    }
}
Пример #2
0
void TextContent::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *)
{
#ifdef ICT
    emit requestEditing();
#else
    emit requestBackgrounding();
#endif
}
Пример #3
0
void AbstractContent::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *)
{
    // emitting the edit request by default. some subclasses request backgrounding
    emit requestEditing();
}