QCamera Example


This Qt C++ application demonstrates how to use Multimedia, Messaging and Contacts modules from Qt Mobility.

The application shows the viewfinder picture from the device camera and allows the user to capture images. Captured images are stored into the gallery and can be sent as an MMS message to a friend. Application listens for incoming MMS messages in the Inbox folder. If the MMS message contains a picture, the application asks the user whether he or she wants to add the picture as an avatar of the sender. The person's general contact information has to exist in the device phonebook in order to store the avatar in it.

The application uses own MyVideoSurface video surface derived from QAbstractVideoSurface for showing camera view finder pictures. A video surface presents a continuous stream of identically formatted frames.

  1. QMediaService* ms = m_camera->service();
  2. QVideoRendererControl* vrc = ms->requestControl<QVideoRendererControl*>();
  3. m_myVideoSurface = new MyVideoSurface(this,this,this);
  4. vrc->setSurface(m_myVideoSurface);

The application handles Graphics Out Of Memory (GOOM) events in it's QApplication::symbianEventFilter() method.

  1.   bool symbianEventFilter( const QSymbianEvent* symbianEvent )
  2.    {
  3.     const TWsEvent *event = symbianEvent->windowServerEvent();
  4.     if ( !event )  {
  5.       return false;
  6.     }
  7.     switch ( event->Type() )  {
  8.       // GOOM handling enabled
  9.       // http://wiki.forum.nokia.com/index.php/Graphics_memory_handling
  10.       case EEventUser:  {
  11.         TApaSystemEvent* eventData = reinterpret_cast<TApaSystemEvent*>(event->EventData());
  12.         if ((*eventData) == EApaSystemEventShutdown)  {
  13.             eventData++;
  14.             if ((*eventData) == KGoomMemoryLowEvent)  {
  15.              return true;
  16.             }
  17.         }
  18.         break;
  19.       }
  20.       default:
  21.         break;
  22.     };
  24.     // Always return false so we don't stop
  25.     // the event from being processed
  26.     return false;
  27.   }

Required capabilities

Application can be self-signed.

After enabling Qt Mobility Messaging module (MESSAGING_ENABLED flag in .pro file) from the project file is ReadDeviceData WriteDeviceData capabilities also needed and application have to be Developer Signed. Enabling Messaging adds MMS sending feature for the application.


Qt SDK 1.1

Qt 4.7.2 for Symbian

QtMobility 1.1.1

Tested on: Nokia N8, Nokia E7

Developed with: Qt SDK 1.1

Notes provided by the Qt Community

No notes