0

I've searched through a number of similar topics but can't find my answer. I'm making a qt app and getting the dreaded Undefined symbols for architecture x86_64: My code looks like
Header file

class LoginWindow : public QWidget {
Q_OBJECT

std::string getUsername();
std::string getPassword();

public slots:
void setUsername (std::string newUsername);
void setPassword (std::string newPassword);

signals:
void loginAttempt();
void usernameChanged(std::string);
void passwordChanged(std::string);

private:
std::string username;
std::string password;
};
}

C file

void LoginWindow::setUsername(std::string newUsername){
username = newUsername;
emit usernameChanged(username);
}

std::string LoginWindow::getUsername(){
return username;
}

std::string LoginWindow::getPassword(){
return password;
}

If I comment out the emit lines everything seems to work fine.

Darakian
  • 619
  • 2
  • 9
  • 22
  • You may not use `emit` keyword. It's just a hint for developers. It's hard to say anything about your problem without compiler logs. If it can not find singal definitions it seems what you forgot to include moc-files in your source. – Deedee Megadoodoo Jan 16 '17 at 15:29
  • 3
    The problem has nothing to do with emit and you don't post complete linker error here. The problem has to do with source code changed but not completely processed. I would force qmake then rebuild. – Alexander V Jan 16 '17 at 15:31
  • If you get that error, that means the compiler could not resolve symbols due to missing libraries or something similar. – DuKes0mE Jan 16 '17 at 15:31
  • If you are using qtcreator try right click on the project and run qmake, and the clean rebuild. This might help. Also i would advice you to use QString as much as possible and only convert to std::string if needed. – Beowolve Jan 16 '17 at 16:17

0 Answers0