# HG changeset patch # User am@osimis.io # Date 1535447377 -7200 # Node ID 38b0ac8055b9939bfae1f45a212c98f8eb08019b # Parent 300d8b8c48b3b0460df92833657a66f9273b7513 Qt: catch and forward keyboard events diff -r 300d8b8c48b3 -r 38b0ac8055b9 Applications/Qt/QCairoWidget.cpp --- a/Applications/Qt/QCairoWidget.cpp Tue Aug 28 10:01:31 2018 +0200 +++ b/Applications/Qt/QCairoWidget.cpp Tue Aug 28 11:09:37 2018 +0200 @@ -29,6 +29,7 @@ QWidget(parent), context_(NULL) { + setFocusPolicy(Qt::StrongFocus); // catch keyPressEvents } QCairoWidget::~QCairoWidget() @@ -134,6 +135,12 @@ } } +void QCairoWidget::keyPressEvent(QKeyEvent *event) +{ + OrthancStone::KeyboardModifiers stoneModifiers = GetKeyboardModifiers(event); + + context_->GetCentralViewport().KeyPressed(event->text()[0].toLatin1(), stoneModifiers); +} void QCairoWidget::resizeEvent(QResizeEvent* event) diff -r 300d8b8c48b3 -r 38b0ac8055b9 Applications/Qt/QCairoWidget.h --- a/Applications/Qt/QCairoWidget.h Tue Aug 28 10:01:31 2018 +0200 +++ b/Applications/Qt/QCairoWidget.h Tue Aug 28 11:09:37 2018 +0200 @@ -51,6 +51,8 @@ virtual void wheelEvent(QWheelEvent *event); + virtual void keyPressEvent(QKeyEvent *event); + public: explicit QCairoWidget(QWidget *parent); diff -r 300d8b8c48b3 -r 38b0ac8055b9 TODO --- a/TODO Tue Aug 28 10:01:31 2018 +0200 +++ b/TODO Tue Aug 28 11:09:37 2018 +0200 @@ -12,6 +12,7 @@ * Allow Interactor to create Pan/ZoomMouseTracker in IWorldSceneMouseTracker* CreateMouseTracker (problem: PanMouseTracker is a IMouseTracker and CreateMouseTracker shall return a IWorldSceneMouseTracker). WorldSceneWidet shall not create Pan/ZoomMouseTracker when the Interactor does not create one +* Update SimpleViewer sample to have 2 buttons to select the measure tracker --------------------------------- Radiotherapy and nuclear medicine