I work with OpenCV and Qt 5. I need to pass the mouse callback to namedwindow for some work that I am doing. However, I cannot make him see any of the private member variables of my class.
Here is the code:
class testWizard : public QWizard { Q_OBJECT public: testWizard(); ~testWizard(); friend void mouseHandler(int, int, int, void*); private: cv::Mat preview; bool drag; cv::Rect rect; };
Friend Function:
void mouseHandler(int event, int x, int y, void* param) { cv::Point p1, p2; if(event == CV_EVENT_LBUTTONDOWN && !drag) { p1 = cv::Point(x,y); drag = true; } if(event == CV_EVENT_LBUTTONDOWN && drag) { cv::Mat temp; preview.copyTo(temp); } }
I do not know what I am doing wrong. I am sure this is the right way to announce this. I am told that preview and drag and drop are undeclared identifiers. Unfortunately, I need to do this this way, since I need access to private members, and passing a pointer to a member function is not possible because of this hidden argument.
Can anyone help? Thanks!
source share