2

I want to run the example found here: http://doc.qt.nokia.com/qtmobility-1.2/samplephonebook.html

But I have an error in this line:

QContactObserver* m_observer;

The error is:

ISO C++ forbids declaration of 'QContactObserver' with no type

in the contacteditor.h file.

What's wrong ? What should I do for that to run?

Mat
  • 202,337
  • 40
  • 393
  • 406
Sonnenschein
  • 169
  • 7
  • 21
  • Is that the only error you get on that file? – Mat Oct 04 '11 at 09:36
  • @Mat : they're 2 errors exactly but i think the second depends on the first ----------->..\EditContacts\/contacteditor.h:64: error: ISO C++ forbids declaration of 'QContactObserver' with no type ..\EditContacts\/contacteditor.h:64: error: expected ';' before '*' token – Sonnenschein Oct 04 '11 at 10:07
  • 1
    you sure have a `#include `, don't you? Be carefull not to include after declaration of namespaces. – mbx Oct 04 '11 at 10:26
  • @mbx : when i include it .. I have an error "no such file or directory" :S – Sonnenschein Oct 04 '11 at 10:47
  • @MarwaShams Probably you don't have the needed file(s) so (re)install the mobility related SDK parts. (or it's just not known to the build system like missing path variable, missing cmake require package) – mbx Oct 04 '11 at 10:52
  • @mbx : I installed the latest SDK beta 1.1 – Sonnenschein Oct 05 '11 at 09:04
  • @MarwaShams have you tried to `find` the file(or used its windows equivalent)? – mbx Oct 05 '11 at 15:43
  • If you don't find it, you may have missed to install the [QtMobility Addon](http://doc.qt.nokia.com/qtmobility-1.2/installation.html). – mbx Oct 05 '11 at 21:40

1 Answers1

1

This question may well have already been solved for the original OP, but for the sake of other users stumbling onto it:

QContactObserver is part of Qt Mobility. Although Qt Mobility is included with the QtSDK, it must be unpacked and built on the development system to ensure that it is configured properly to be used in a project on that system.

In addition, the .pro file requires additions to prompt it to include the required Qt Mobility headers. For example, QContactObserver is part of the QtContacts module, so the .pro file would require the follwing additional lines:

CONFIG += mobility
MOBILITY += contacts

The error mentioned in the comments above:

MBX: you sure have a #include <QContactObserver>, don't you?

Marwa Shams: when i include it .. I have an error "no such file or directory"

occurs because Qt does not know where to look for the <QContactObserver> headers. Following the steps above will remedy the problem.

Community
  • 1
  • 1
sam-w
  • 7,478
  • 1
  • 47
  • 77