Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Camera Key Event Disposal in Qt on Symbian

From Wiki
Jump to: navigation, search

On Symbian the camera hardware key launches the native camera app. This article explains how to dispose of the camera key event so that the key can be used to take pictures using your own Qt app.

Note.pngNote: This is an entry in the PureView Imaging Competition 2012Q2

Article Metadata
Compatibility
Platform(s): Qt 4.6 and later
Article
Keywords: Camera
Created: r60600 (08 May 2012)
Last edited: hamishwillee (30 May 2013)

Introduction

Mobile users often use the camera key when they capture image or video. So the developers must add key event disposal in their Qt application.

After Qt 4.7,there are 2 enumerations in the qnamespace.h: Qt::Key_Camera and Qt::Key_CameraFocus

The usual camera key event disposal way is

void Camera::keyPressEvent(QKeyEvent * event)
{
if (event->isAutoRepeat())
return;
 
switch (event->key()) {
#if QT_VERSION >= 0x040700
case Qt::Key_CameraFocus:
 
//focus operation
 
event->accept();
break;
case Qt::Key_Camera:
 
//capture operation
 
event->accept();
break;
#endif
default:
QMainWindow::keyPressEvent(event);
}
}
 
void Camera::keyReleaseEvent(QKeyEvent * event)
{
if (event->isAutoRepeat())
return;
 
switch (event->key()) {
#if QT_VERSION >= 0x040700
case Qt::Key_CameraFocus:
 
//Un-focus operation
 
break;
#endif
default:
QMainWindow::keyReleaseEvent(event);
}
}

Last, application had better add a listener to dispose Symbian camera key event for Symbian device like this:

#include "camerakeyevent_symbian.h"
 
...
#if defined (Q_OS_SYMBIAN)
 
QApplication::setGraphicsSystem("raster");
 
QApplication app(argc, argv); // lock orientation before constructing camera
 
CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
 
if(appUi){QT_TRAP_THROWING(appUi ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));}
...
 
new QSymbianCameraKeyListener(&camera);
 
#endif
This page was last modified on 30 May 2013, at 06:33.
60 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×