Qt 5 C++ undefined reference to Class::function(QString, Qstring, ...) -
i know question has been answered in forum before, need more specific help.
here's code:
sessionwindow.cpp
#include "sessionwindow.h" #include "ui_sessionwindow.h" #include "session.h" #include "utils.h" #include <qstringlist> sessionwindow::sessionwindow(qwidget *parent) : qdialog(parent), ui(new ui::sessionwindow) { ui->setupui(this); this->setfixedsize(this->size()); } sessionwindow::~sessionwindow() { delete ui; } void sessionwindow::on_cancelbtn_clicked() { close(); } void sessionwindow::on_createbtn_clicked() { qstring min = (ui->ismin) ? "min" : "nomin"; qstring sp = (ui->sphidd) ? "nosp" : "sp"; qstring name = ui->sessionname->text(); qstring user = ui->skuser->text(); qstring pass = ui->skpass->text(); utils u; u.createsession(name, user, pass, min, sp); }
utils.h (where function prototype declared)
#ifndef utils_h #define utils_h #include <qstring> #include <qstringlist> class utils { public: utils(); ~utils(); void startskype(qstring, qstring, qstringlist); void createsession(qstring , qstring, qstring, qstring, qstring); }; #endif // utils_h
utils.cpp (where function is)
#include "utils.h" #include "session.h" #include <qstring> #include <qstringlist> #include <qvector> #include <qdebug> qvector<session> sessions; utils::utils() { } utils::~utils() { } void utils::startskype(qstring user, qstring pass, qstringlist options) { } void createsession(qstring name, qstring user, qstring pass, qstring ismin, qstring sphid) { sessions.append(session(name, user, pass, ismin, sphid)); }
the problem tha can't compile it, throws error: undefined reference `utils::createsession(qstring, qstring, qstring, qstring, qstring)'
sorry if explained bad , help!! :d
you forgot put utils::
in front of method definition:
void createsession(qstring name, qstring user, qstring pass, qstring ismin, qstring sphid) { sessions.append(session(name, user, pass, ismin, sphid)); }
should be
void utils::createsession(qstring name, qstring user, qstring pass, qstring ismin, qstring sphid) { sessions.append(session(name, user, pass, ismin, sphid)); }
Comments
Post a Comment