-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qt virtual QObject #419
Comments
Wow, yes, that does work! We'll just need to figure out where to plug this in here: |
I've fixed this issue and virtualized |
Hi @saudet, thank you for the patch! I already tried a manually patched version and I found another problem. My Plan is to write a class A way to fix this is extending all -class JavaCPP_hidden JavaCPP_QCoreApplication : public QCoreApplication {
+class JavaCPP_hidden JavaCPP_QCoreApplication : public QCoreApplication, public JavaCPP_QObject { In this case, my |
If you're subclassing |
Hi @saudet , I added an example, please have a look. It should just print "customEvent", but it will crash with a stack overflow. The Event Loop Because
Here, |
Actually, there was another issue with JavaCPP not picking up virtual methods specified with Your |
Hi @saudet, thank you very much, the virtual stuff is working now! But there is still another problem. When you set a breakpoint in function customEvent in my example application, you can see, that the event argument is of type |
Right, that's expected. We'd have to add some sort of introspection mechanism.
|
The easiest thing to do for now is to use the address as a key to a HashMap, like this: |
Hi,
I'm trying to implement a custom event function in a class extending
QApplication
.When overriding this function in java, the new implementation is not called.
Also, this function is missing on the java side:
To fix this, I added this function to
qt/src/main/java/org/bytedeco/qt/presets/Qt5Core.java
:I'm using
mvn install -DskipTests=true -Djavacpp.cppbuild.skip
to update the generated files.This changes will be created in
qt/src/gen/java/org/bytedeco/qt/Qt5Core/QObject.java
:But compiling fails:
qobject.h
:qcoreapplication.h
:Because it is protected in QCoreApplication, it can not be called here (
jniQt5Core.cpp
):In this line:
bool rval = (bool)(dynamic_cast<JavaCPP_QCoreApplication*>(ptr) != NULL ? ((JavaCPP_QCoreApplication*)ptr)->super_event(ptr0) : ptr->event(ptr0));
,when
ptr
is of typeQCoreApplication
,ptr->event
is not valid, because it is protected.I tried this changes:
In file
org.bytedeco.qt.presets.Qt5Core
, in functionpublic void map(InfoMap infoMap)
I addedthis will rename the function as expected. But changing it to:
nothing will be changed. Also
and adding
"QCoreApplication::event"
toprotected String[] skip()
is not possible.Maybe changing
ptr->event(ptr0)
to((QObject*)ptr)->event(ptr0)
will work?Is there a way to fix this?
The text was updated successfully, but these errors were encountered: