Closed NielsMayer closed 1 year ago
This warning for
class PaintingItemPainter: public QObject, public QNanoQuickItemPainter
is part of the problem:
paintingitempainter.h:37:28: Direct base 'QObject' is inaccessible due to ambiguity:
class PaintingItemPainter -> QObject
class PaintingItemPainter -> QNanoQuickItemPainter -> QQuickRhiItemRenderer -> QObject
Thanks! I tested with latest 6.7.0 dev MSVC2019 package from Qt installer and don't get errors. But I do see that warning which comes because QQuickRhiItemRenderer is inherited from QObject. I made a Qt ticket to consider this (QTBUG-117921) as well as patch to remove warning with the current dev.
Unfortunately, with no workaround for this problem, qRHI support cannot be tested on any Linux or Android platform. Although the warning indicates the source of the problem, compilation fails because of it on both Linux and Android.
For example on Android:
/opt/google/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -c -target x86_64-linux-android23 -fno-limit-debug-info -fPIC -fstack-protector-strong -DANDROID -O2 -std=gnu++1z -Wall -W -fPIC -D_REENTRANT -DQNANO_QT_GL_INCLUDE -DQNANO_USE_RHI -DQNANO_ENABLE_GLES3 -D_CRT_SECURE_NO_WARNINGS -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QMLINTEGRATION_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../../qnanopainter/examples/qnanopainter_vs_qpainter_demo -I. -I../../../qnanopainter/libqnanopainter -I/opt/QtCo/6.7.0/android_x86_64/include -I/opt/QtCo/6.7.0/android_x86_64/include/QtQuick -I/opt/QtCo/6.7.0/android_x86_64/include/QtOpenGL -I/opt/QtCo/6.7.0/android_x86_64/include/QtGui/6.7.0 -I/opt/QtCo/6.7.0/android_x86_64/include/QtGui/6.7.0/QtGui -I/opt/QtCo/6.7.0/android_x86_64/include/QtGui -I/opt/QtCo/6.7.0/android_x86_64/include/QtQmlModels -I/opt/QtCo/6.7.0/android_x86_64/include/QtQml -I/opt/QtCo/6.7.0/android_x86_64/include/QtQmlIntegration -I/opt/QtCo/6.7.0/android_x86_64/include/QtNetwork -I/opt/QtCo/6.7.0/android_x86_64/include/QtCore/6.7.0 -I/opt/QtCo/6.7.0/android_x86_64/include/QtCore/6.7.0/QtCore -I/opt/QtCo/6.7.0/android_x86_64/include/QtCore -I. -I/opt/QtCo/6.7.0/android_x86_64/mkspecs/android-clang -o moc_qnanowindow.o moc_qnanowindow.cpp
In file included from ../../../qnanopainter/examples/gallery/painting/src/paintingitem.cpp:1:
In file included from ../../../qnanopainter/examples/gallery/painting/src/paintingitem.h:4:
In file included from ../../../qnanopainter/libqnanopainter/qnanoquickitem.h:26:
In file included from /opt/QtCo/6.7.0/android_x86_64/include/QtQuick/QQuickRhiItem:1:
In file included from /opt/QtCo/6.7.0/android_x86_64/include/QtQuick/qquickrhiitem.h:7:
In file included from /opt/QtCo/6.7.0/android_x86_64/include/QtQuick/QQuickItem:1:
In file included from /opt/QtCo/6.7.0/android_x86_64/include/QtQuick/qquickitem.h:8:
In file included from /opt/QtCo/6.7.0/android_x86_64/include/QtQml/qqml.h:7:
In file included from /opt/QtCo/6.7.0/android_x86_64/include/QtQml/qqmlprivate.h:18:
In file included from /opt/QtCo/6.7.0/android_x86_64/include/QtQml/qjsprimitivevalue.h:12:
In file included from /opt/QtCo/6.7.0/android_x86_64/include/QtCore/qvariant.h:25:
/opt/QtCo/6.7.0/android_x86_64/include/QtCore/qobject.h:234:28: error: ambiguous conversion from derived class 'const typename QtPrivate::FunctionPointer<void (PaintingItemPainter::*)()>::Object' (aka 'const PaintingItemPainter') to base class 'const QObject':
class PaintingItemPainter -> class QObject
class PaintingItemPainter -> class QNanoQuickItemPainter -> class QQuickRhiItemRenderer -> class QObject
return connectImpl(sender, reinterpret_cast<void **>(&signal), context, pSlot,
^~~~~~
../../../qnanopainter/examples/gallery/painting/src/paintingitem.cpp:13:14: note: in instantiation of function template specialization 'QObject::connect<void (PaintingItemPainter::*)(), void (QQuickItem::*)()>' requested here
QObject::connect(itemPainter, &PaintingItemPainter::update, this, &PaintingItem::update);
^
1 warning and 1 error generated.
make[1]: *** [Makefile:5677: paintingitem.o] Error 1
make[1]: *** Waiting for unfinished jobs....
I still feel there is a way to work around this problem, perhaps using a casting macro with internal ifdefs depending on whether qRHI backend is used. However, the more i try to work around this, the more messy this gets, and still ends up with non-compilable code....
Seems like a common problem: https://forum.qt.io/topic/116663/problems-with-object-design-how-to-get-over-ambiguous-warnings/3 https://forum.qt.io/topic/88295/with-qt-5-6-is-it-possible-to-avoid-the-diamond-problem-when-signals-and-slots-are-defined-in-two-branches
And an old problem: https://stackoverflow.com/questions/7903342/qobject-inheritance-ambiguous-base https://stackoverflow.com/questions/30266816/qt-inheritance-cause-ambiguous https://stackoverflow.com/questions/2595849/how-can-i-inherit-from-both-qwidget-and-qthread
So you get this error still with latest dev including https://github.com/QUItCoding/qnanopainter/commit/09b6b3cdbc76951c6dc0fee48ae5386f59db29ab ? It should work.
Your latest fixes have resolved the issue for both Android and Linux. Thanks!
I just updated, via QtInstaller, to 6.7.0-0-20231003103 "dev" release, which appears to have qRHI headers.
I was curious to try out this significant update to Qt6 compatibility and future-proofing for qnanopainter (thanks for doing it!).
However, when compiling "gallery" with "DEFINES += QNANO_USE_RHI" I get a compilation error for
QObject::connect(itemPainter, &PaintingItemPainter::update, this, &PaintingItem::update);
This is the error:
Full compilation log output is here: gallery-compile.txt
I also noticed Qt6.7 being fussy about other casts, especially of functions. When I get time I'll look into throwing a couple of
(void *)
here and there, which is how I fixed a heinous compilation error involving previously working Qt Android JNI code. And I haven't been able to fix it the "right way" with reinterpret_cast(...) because that doesn't work for function casts. Maybe if someone shows me the "right" way to fix this new 6.7 problem here, I'll be able to use that to fix my(void*)
hack elsewhere.