0

QGeoRoutingManager: http://apidocs.meego.com/1.0/qtmobility/qgeoroutingmanager-members.html

This class doesn't have a constructor. I have forgotten the way to allocate memory to its pointer.

I did:

QGeoRoutingManager *a = new QGeoRoutingManager ();

This lands in the error:

calculateRoute.cpp:16: error: no matching function for call to ‘QtMobility::QGeoRoutingManager::QGeoRoutingManager()’
../../../../tarBalls/qt-mobility-opensource-src-1.2.0/install/include/QtLocation/qgeoroutingmanager.h:91: note: candidates are: QtMobility::QGeoRoutingManager::QGeoRoutingManager(const QtMobility::QGeoRoutingManager&)

What should I pass in there, as per the error message "const QtMobility::QGeoRoutingManager&"

Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411

5 Answers5

5

This is a singleton class, you can access it like this:

QGeoServiceProvider::routingManager().

Check the docs

sergio
  • 68,819
  • 11
  • 102
  • 123
2

If the class doesn't have a public (default) constructor, you can't (directly) create a new instance of it, neither on the stack nor on the free store (heap). You could only possibly create a copy of an existing one, but the docs don't show a copy ctor available.

Look through the documentation if there is a factory function / class to create instances of that class.

Xeo
  • 129,499
  • 52
  • 291
  • 397
0

The class QGeoRoutingManager does not have default constructor. The default constructor is one which doesn't take any argument. If it takes, then they're optional (with default value).

Nawaz
  • 353,942
  • 115
  • 666
  • 851
  • 1
    It has one, yes, but the error clearly shows it's not public. – Xeo May 24 '11 at 07:28
  • @Xeo: I don't see that error clearly says that. Can you help me? – Nawaz May 24 '11 at 07:30
  • @Nawaz and @Xeo Did both of you click the link I posted? I couldn't find a default constructor there. This link uses an object of the same class but the way to allocate memory is not shown anywhere.:http://apidocs.meego.com/1.2-preview/qtmobility/qgeoroutingmanager.html#details – Aquarius_Girl May 24 '11 at 07:30
  • QGeoRoutingManager might be written as an interface (Or a class that is not supposed to directly instantiate). Check if you need a derived class!! – Mayank May 24 '11 at 07:30
  • 1
    @Nawaz: Since every class automatically gets a default ctor, if it can't find one, it must be non-public. – Xeo May 24 '11 at 07:30
  • 1
    @Xeo: NO, every class doesn't automatically gets default ctor. If you define a ctor that takes parameter, then the compiler doesn't generate default ctor for you. – Nawaz May 24 '11 at 07:31
  • @Nawaz: Derp, I'm sleep deprived, excuse that brainfart. :| But the error also only shows the copy ctor as another possibility, so I guess I somehow connected that... – Xeo May 24 '11 at 07:34
  • @Xeo: Anyhow, the error doesn't show that "it has default constructor but it is not public". :D – Nawaz May 24 '11 at 07:36
  • 1
    @Nawaz: Stop editing your comments to have a completely different meaning. ;P – Xeo May 24 '11 at 07:37
  • @Xeo: OP might call `a.foo()`, does that mean that `foo()` exists in the class? – Nawaz May 24 '11 at 07:38
  • @Xeo: See its you who edited your comment. :P.. (Also I just edited my commment to direct my comment at you. I mistakenly wrote @Nawaz, rather than @Xeo :P). – Nawaz May 24 '11 at 07:40
0

I think you need QGeoRoutingManager * QGeoServiceProvider::routingManager () const

Check here: https://doc-snapshots.qt.io/qt-mobility/qgeoserviceprovider.html

Christophe Weis
  • 2,518
  • 4
  • 28
  • 32
Mayank
  • 5,454
  • 9
  • 37
  • 60
0

The class does have a constructor; all classes have a constructor. The class apparently doesn't have a default constructor. You don't show us the class, so we have to guess, but from the error message, the class does have a copy constructor. Did you provide it? As soon as there are any user defined constructors, the compiler will not generate a default constructor; you have to provide one of those too.

James Kanze
  • 150,581
  • 18
  • 184
  • 329