c++ - Unresolved External Symbol in QT connect() -
i´m pretty new qt , c++ , i´m getting error can´t manage solve. i´m trying connect currentrowchanged() signal of tableview selection model slot created can data row selected.
this code: opciones.cpp
#include "opciones.h" #include "ui_opciones.h" #include <qsqldatabase.h> #include <qsqlquery.h> #include <qdebug.h> #include <qmessagebox.h> #include <qsqltablemodel.h> #include <qitemselectionmodel.h> #include "qmodelindex" opciones::opciones(qwidget *parent) : qdialog(parent), ui(new ui::opciones) { .... connect(ui->tablajuegos->selectionmodel(),signal(currentrowchanged(const qmodelindex & current, const qmodelindex & previous)), this,slot(filaseleccionada(const qmodelindex & current, const qmodelindex & previous))); db.close(); } opciones::~opciones() { delete ui; } void filaseleccionada(const qmodelindex & current, const qmodelindex & previous){ } opciones.h
#ifndef opciones_h #define opciones_h #include <qdialog> #include <qmodelindex> namespace ui { class opciones; } class opciones : public qdialog { q_object public: explicit opciones(qwidget *parent = 0); ~opciones(); private slots: void on_pushbutton_2_clicked(); void on_pushbutton_3_clicked(); public slots: void filaseleccionada(const qmodelindex & current, const qmodelindex & previous); private: ui::opciones *ui; }; #endif // opciones_h i´m having problems connect() function giving me following error:
moc_opciones.obj:-1: error: lnk2019: unresolved external symbol "public: void __cdecl opciones::filaseleccionada(class qmodelindex const &,class qmodelindex const &)" (?filaseleccionada@opciones@@qeaaxaebvqmodelindex@@0@z) referenced in function "private: static void __cdecl opciones::qt_static_metacall(class qobject *,enum qmetaobject::call,int,void * *)" (?qt_static_metacall@opciones@@caxpeavqobject@@w4call@qmetaobject@@hpeapeax@z) the variable tablajuegos tableview created in ui designer of qt.can tell me i´m doing wrong?
thanks help
in opciones.cpp haven't declared filaseleccionada scoped within opciones class. declare way:
void opciones::filaseleccionada(const qmodelindex & current, const qmodelindex & previous){ } what you've done in code declare new free function, filaseleccionada. compiler has no problem this, fine have both free function , class-scoped method same name. moreover, @ link time there still not error, since not calling opciones::filaseleccionada directly anywhere. therefore, problem first encountered connect().
Comments
Post a Comment