Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am starting to leran QT. doing small tasks for learning. I am getting error "Undefined reference to mymainwindow::mytestfunctiontocall"
here is my code how i am doing

in mymainwindow.h
public
     void mytesfunctioncall();


in mymainwindow.cpp
void myMainwindow::on_Push_Button_clicked()
{
    mytestfunctiontocall()
}
mytestfunctiontocall()
{
   qDebug() << "Hello world msg";
}
Posted

Quote:
public
void mytesfunctioncall();
This is not valid C++ code.
It is better if you post the actual code, in order to get proper help.
 
Share this answer
 
v2
Comments
XamBEE 18-Nov-15 6:53am    
its
class Mainwindow:public QMainWindow
{
public:
void mytesfunctioncall();
}
in mainwindow.h file
Most of that code is wrong, you should spend more time studying C++ before trying to learn Qt.
Assuming that your header file contains a proper class declaration for myMainwindow, then the .cpp file should look something like the following, and use the same method name as declared in the header:
C++
void myMainwindow::on_Push_Button_clicked()
{
    mytesfunctioncall();
}
void myMainwindow::mytesfunctioncall()
{
   qDebug() << "Hello world msg";
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900