Well, this looks like c++ mistake:
When you implement a function in a class, you have to prepend the name of the class and the resolution operator to it:
Key::Key KeyDialog::getKey()
{
return K2;
}
Key::Key KeyDialog::getKey()
{
return K2;
}
To copy to clipboard, switch view to plain text mode
Now, K2 has to be a member of the class in order to be visible in any of the class's member functions.
Also, the correct thing to do is:
void MainWindow::on_push_0_clicked()
{
KeyDialog dialog(this);
dialog.setKey(zero);
if(dialog.
exec() == QDialog::Accepted ) {
Key::Key k = dialog.getKey();
resetKey(k);
}
}
void MainWindow::on_push_0_clicked()
{
KeyDialog dialog(this);
dialog.setKey(zero);
if(dialog.exec() == QDialog::Accepted )
{
Key::Key k = dialog.getKey();
resetKey(k);
}
}
To copy to clipboard, switch view to plain text mode
exec(), by default, returns an exit code which shows you whether the user pressed ok or cancel( accepted or rejected).
So you need to call exec only once.
The compile errors tell you that you did not declared/defined the getKey function.
To declare a function - means you add it in the class declaration, in the header:
class KeyDialog : ...
{
public:
Key::Key getKey();
};
class KeyDialog : ...
{
public:
Key::Key getKey();
};
To copy to clipboard, switch view to plain text mode
The function definition means the implementation. It appears that you have donh that( incorrectly although ).
So, fix these errors and try again.
Regards
Bookmarks