Hello! jpn,
Thanks for replying and showing me that site. But Sir i know C++ programming, what i dont know is can we call that function from GUI .cpp file or not. Sir it is serious!!!!
Below are the files: -
/////////-------Square.h---------///////////
#ifndef SQUARE_H
#define SQUARE_H
#include<iostream>
class Square
{
public:
Square();
int Square_of(int);
}
#endif
////////----End of file-------/////////
/////////-------Square.h---------///////////
#ifndef SQUARE_H
#define SQUARE_H
#include<iostream>
class Square
{
public:
Square();
int Square_of(int);
}
#endif
////////----End of file-------/////////
To copy to clipboard, switch view to plain text mode
///////-----Suare.cpp------//////////
#include<square.h>
int Square::Square_of( i )
{
return i*i;
}
/////////-------End of file------/////////
///////-----Suare.cpp------//////////
#include<square.h>
int Square::Square_of( i )
{
return i*i;
}
/////////-------End of file------/////////
To copy to clipboard, switch view to plain text mode
////////-------testform.ui.h 'which is GUI form's file'------//////////
#include<square.h>
void testForm::square()
{
int i = inputLineEdit->text().toInt();
int sq = Square_of(i);
resultLineEdit
->setText
(QString::number(sq,
10));
}
void testForm::init()
{
resultLineEdit->setText("2");
resultLineEdit->selectAll();
}
///////------End of file-------///////////
////////-------testform.ui.h 'which is GUI form's file'------//////////
#include<square.h>
void testForm::square()
{
int i = inputLineEdit->text().toInt();
int sq = Square_of(i);
resultLineEdit->setText(QString::number(sq,10));
}
void testForm::init()
{
resultLineEdit->setText("2");
resultLineEdit->selectAll();
}
///////------End of file-------///////////
To copy to clipboard, switch view to plain text mode
/////////-------main.cpp 'which is GUI's execution file---------/////////
#include <qapplication.h>
#include "test1form.h"
int main( int argc, char ** argv )
{
test1Form w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
////////------End of file-----/////////
/////////-------main.cpp 'which is GUI's execution file---------/////////
#include <qapplication.h>
#include "test1form.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
test1Form w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
////////------End of file-----/////////
To copy to clipboard, switch view to plain text mode
When i tried to execute it like by using qmake & make it showed me some errors: -
square.cpp:5: error: extraneous `int' ignored
square.cpp:5: error: `Square Square::Square_of' is not a static member of `class Square'
square.cpp:5: error: `i' was not declared in this scope
square.cpp:6: error: expected `,' or `;' before '{' token
make: *** [.obj/square.o] Error 1
Can you please let me know what is causing these error's.
I will be obliged if helped.-------->Thanks in Advance.
Bookmarks