Calling function from reimplemented QApplication / notify
-
Again: the error you are getting does not come from the compiler: so all the C++ includes are fine. The linker does not see the (already compiled) object code, which means something is wrong in your build setup. Either a library not included, or qtgui_mainwindow.o is not present.
-
Hmmm...
If I only comment out the call
@TouchEventForTCO(event->type(), cursorPos.rx(), cursorPos.ry());@everything builds and runs perfect.
qtgui_mainwindow.o is present. -
run qmake?
-
qmake didn't help.
-
Anybody else an idea what I have set wrong to have the linker giving this error?
-
Solved it. Changed call to:
@QTGUI_MainWindow::TouchEventForTCO(event->type(), cursorPos.rx(), cursorPos.ry()); @
and made TouchEventForTCO() static and public.I don't know if this is the "correct" way .. however, it works :)
Thanks everybody for their help. -
Too happy too soon ;)
I can now call TouchEventForTCO() and also read the arguments, copy them ... whatever. However, as soon as I call another function from inside TouchEventForTCO() I get back to the same problem and I get:
@..\src\qtgui_mainwindow.cpp: In static member function 'static void QTGUI_MainWindow::TouchEventForTCO(int, int, int)':
..\src\qtgui_mainwindow.cpp:1851: error: cannot call member function 'void QTGUI_MainWindow::PrepareForTCO(QByteArray*)' without object
@
I somehow cant believe that I have to make every function public that need to be called down the line.
How do I solve this the correct way in C++? -
You are really not having Qt-Trouble, bu C++ trouble...
Check C++ - tutorials, what static means pls :-/ In short: Static-Functions are called without an object. So you cant call non-static-functions from within a static function, because non-static function need an object.
"static functions" in object oriented world is comparable to "global functions" in functional world, but static functions belong to a classes namespace.
Best Regards.
-
You're right. It's a C++ issue, not Qt.
So, making TouchEventForTCO() static and public is not the correct way, I assume. If not, how do I call QTGUI_MainWindow::TouchEventForTCO from the MyApplication::notify in the other class then (see code snippets above)? -
I cant really tell you with that little code-examples... regarding your very first post it seems that you have not implemented your constructor. Another C++-thing...