I am new in C++ and working on a project with QT. I created a header file called imageconvert.h which is as follow:
class ImageConvert
{
private:
IplImage *imgHeader;
uchar* newdata;
public:
ImageConvert();
~ImageConvert();
IplImage* QImage2IplImage(QImage *qimg);
QImage* IplImage2QImage(IplImage *iplImg);
};
also I defined those public methods in imageconvert.cpp file.
Now, I want to call QImage2IplImage and IplImage2QImage from other cpp file. So i include imageconvert.h in that CPP file and called those two functions.
it gives the the following errors:
error: 'QImage2IplImage' was not declared in this scope
error: 'IplImage2QImage' was not declared in this scope
Any help would be greatly appreciated.
The functions you’ve defined are member functions of the
ImageConvertclass. You need an instance of that class to be able to call them.Something like:
If you don’t need state to do the conversion, you should make those helper functions
static. Then you can call them with:without first creating an instance of
ImageConvert. But please note that you will not be able to useimgHeaderornewDatain those static functions – they are member variables, only usable within an instance of that class.You could also remove these functions from your class and put them in a
namespace.