I'm developing a standalone QT 5.11.2 application using QGIS 3.6 C++ API.

I have defined a slot that is meant to consume a currentLayerChanged(QgsMapLayer * layer) signal.

The slot declaration in the header file is:

private slots:
    void on_CurrentLayer_changed(QgsMapLayer *layer);

The slot definition is:

void MainWindow::on_CurrentLayer_changed(QgsMapLayer *  layer)
    // do something here

When I try to build I get a linker error:

moc_mainwindow.obj:-1: error: LNK2019: símbolo externo "public: static struct QMetaObject const QgsMapLayer::staticMetaObject" (?staticMetaObject@QgsMapLayer@@2UQMetaObject@@B) sin resolver al que se hace referencia en la función "int __cdecl qRegisterMetaType<class QgsMapLayer *>(char const *,class QgsMapLayer * *,enum QtPrivate::MetaTypeDefinedHelper<class QgsMapLayer *,1>::DefinedType)" (??$qRegisterMetaType@PEAVQgsMapLayer@@@@YAHPEBDPEAPEAVQgsMapLayer@@W4DefinedType@?$MetaTypeDefinedHelper@PEAVQgsMapLayer@@$00@QtPrivate@@@Z)
File not found: moc_mainwindow.obj
error: LNK1120: 1 externos sin resolver

Should I subclass any of the classes that emit the signal currentLayerChanged(QgsMapLayer * layer) to define the slot?

I've also posted it at stackoverflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.