February 29, 2012

Vetryaspa Vetryaspa
Lab Rat
87 posts

[SOLVED]not found slots but the slots thera are!!

 

Hi all,
I have a problem because I use the Location api for found latitude and longitude, this is my constructor:

  1. GeoLocalizzazione::GeoLocalizzazione()
  2. {
  3.     _updateArrived = false;
  4.     _locationInfo = QGeoPositionInfoSource::createDefaultSource(this);
  5.     qDebug() << "Metodi supportati: " << (int)(_locationInfo->supportedPositioningMethods());
  6.     _locationInfo->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
  7.     QObject::connect(_locationInfo, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
  8.     QObject::connect(_locationInfo, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
  9.     //_locationInfo->setUpdateInterval(1000);
  10.     _locationInfo->requestUpdate(5000);
  11.     _locationInfo->startUpdates();
  12.     qDebug() << "requestUpdates";
  13.     QTimer::singleShot(30000, this, SLOT(timerExpired()));
  14. }

the log of debug are this:

  1. Object::connect: No such slot QWidget::positionUpdated(QGeoPositionInfo) in ..\GamberoRosso\GeoLocalizzazione\geolocalizzazione.cpp:12
  2. Object::connect: No such slot QWidget::updateTimeout() in ..\GamberoRosso\GeoLocalizzazione\geolocalizzazione.cpp:13
  3. requestUpdates
  4. Object::connect: No such slot QWidget::timerExpired() in ..\GamberoRosso\GeoLocalizzazione\geolocalizzazione.cpp:18

but this is my h file:

  1. QTM_USE_NAMESPACE;
  2.  
  3. namespace Ui {
  4.     class GeoLocalizzazione;
  5. }
  6.  
  7. class GeoLocalizzazione : public QWidget
  8. {
  9.  
  10. public:
  11.     GeoLocalizzazione();
  12.  
  13. private:
  14.  
  15.     //DICHIARAZIONE VARIABILI
  16.     QString globalNavigation;
  17.     QGeoPositionInfoSource* _locationInfo;
  18.     bool _updateArrived;
  19.  
  20. protected slots:
  21.  
  22.     void timerExpired();
  23.     void updateTimeout();
  24.     void positionUpdated(QGeoPositionInfo geoPositionInfo);
  25.  
  26.  
  27. };

why not get the slots?

5 replies

February 29, 2012

mlong mlong
Robot Herder
1551 posts

Add the Q_OBJECT macro to your GeoLocalizzazione class definition. Moc needs that to process signals and slots correctly.

 Signature 

Senior Software Engineer
AccuWeather Enterprise Solutions
/* My views and opinions do not necessarily reflect those of my employer.  Void where prohibited. */

February 29, 2012

koahnig koahnig
Gene Splicer
2907 posts

You may want to add the Q_OBJECT macro in your class definition.

  1. class GeoLocalizzazione : public QWidget
  2. {
  3.      Q_OBJECT
  4.  
  5. public:
  6.     GeoLocalizzazione();
  7.  
  8. private:
  9.  
  10.     //DICHIARAZIONE VARIABILI
  11.     QString globalNavigation;
  12.     QGeoPositionInfoSource* _locationInfo;
  13.     bool _updateArrived;
  14.  
  15. protected slots:
  16.  
  17.     void timerExpired();
  18.     void updateTimeout();
  19.     void positionUpdated(QGeoPositionInfo geoPositionInfo);
  20.  
  21.  
  22. };

[edit] a couple of seconds late :-(

February 29, 2012

Deleted Member # 269f Deleted Member # 269f
Lab Rat
251 posts

Or select a Qt baseclass for your class from the new class dialog and have Creator do it for you :)

February 29, 2012

Andre Andre
Robot Herder
6420 posts

Note that you probably want to re-run qmake as well, after adding the Q_OBJECT macro.

February 29, 2012

Vetryaspa Vetryaspa
Lab Rat
87 posts

Tnx all, i have put Q_Object macro befor send this post but I not have try to run qmake… now it run!!!

Tnx All!!! :)

 
  ‹‹ How to make a QGraphicsEffect show?      Simple DOM Model - making it editable - inserting rows ››

You must log in to post a reply. Not a member yet? Register here!