Skip to content
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 6.9 not compiling - QObjectData_dynamicMetaObject invalid conversion from const #194

Open
emad-elsaid opened this issue Apr 10, 2025 · 13 comments · Fixed by #195 · May be fixed by #199
Open

Qt 6.9 not compiling - QObjectData_dynamicMetaObject invalid conversion from const #194

emad-elsaid opened this issue Apr 10, 2025 · 13 comments · Fixed by #195 · May be fixed by #199
Labels
bug Something isn't working

Comments

@emad-elsaid
Copy link

When trying to compile the webEngine example I'm getting an error:

package main

import (
	"os"

	"github.com/mappu/miqt/qt"
	"github.com/mappu/miqt/qt6/webengine"
)

func main() {
	qt.NewQApplication(os.Args)
	w := webengine.NewQWebEngineView2()
	w.Load(qt.NewQUrl3("https://github.com/mappu/miqt"))
	w.Show()

	qt.QApplication_Exec()
}

my go.mod

module github.com/emad-elsaid/example

go 1.24.2

require github.com/mappu/miqt v0.9.0 // indirect

The error I'm getting:

➜ go run  -ldflags '-s -w' .
# github.com/mappu/miqt/qt6
gen_qobject.cpp: In function ‘QMetaObject* QObjectData_dynamicMetaObject(const QObjectData*)’:
gen_qobject.cpp:40:39: error: invalid conversion from ‘const QMetaObject*’ to ‘QMetaObject*’ [-fpermissive]
   40 |         return self->dynamicMetaObject();
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~
      |                                       |
      |                                       const QMetaObject*

tried with dynamic linking:

CGO_ENABLED=1 go run -ldflags="-linkmode=external" .
# github.com/mappu/miqt/qt6
gen_qobject.cpp: In function ‘QMetaObject* QObjectData_dynamicMetaObject(const QObjectData*)’:
gen_qobject.cpp:40:39: error: invalid conversion from ‘const QMetaObject*’ to ‘QMetaObject*’ [-fpermissive]
   40 |         return self->dynamicMetaObject();
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~
      |                                       |
      |                                       const QMetaObject*
@mappu
Copy link
Owner

mappu commented Apr 10, 2025

Thanks for trying miqt! What OS + version of Qt do you have?

@mappu mappu added the troubleshooting Investigating an issue to determine its status label Apr 10, 2025
@mappu
Copy link
Owner

mappu commented Apr 10, 2025

It looks like QObject::dynamicMetaObject changed return type to const in Qt 6.9 released last week:

Miqt will need a small update in order to work with Qt 6.9. This can be easily fixed with genbindings/config-allowlist.go ApplyQuirks function to set the BecomesNonConstInVersion quirk for this method.

@mappu mappu changed the title WebEngine example not compiling Qt 6.9 not compiling - QObjectData_dynamicMetaObject invalid conversion from const Apr 10, 2025
@mappu mappu added bug Something isn't working and removed troubleshooting Investigating an issue to determine its status labels Apr 10, 2025
@rcalixte
Copy link
Contributor

Miqt will need a small update in order to work with Qt 6.9. This can be easily fixed with genbindings/config-allowlist.go ApplyQuirks function to set the BecomesNonConstInVersion quirk for this method.

This seems to be slightly more annoying to address:

diff --git a/qt6/gen_qobject.cpp b/qt6/gen_qobject.cpp
index 7c2a5635..b57d1418 100644
--- a/qt6/gen_qobject.cpp
+++ b/qt6/gen_qobject.cpp
@@ -36,7 +36,7 @@ void miqt_exec_callback_QObject_disconnectNotify(QObject*, intptr_t, QMetaMethod
 } /* extern C */
 #endif
 
-QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self) {
+const QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self) {
        return self->dynamicMetaObject();
 }
 
diff --git a/qt6/gen_qobject.h b/qt6/gen_qobject.h
index 47606a20..2597e069 100644
--- a/qt6/gen_qobject.h
+++ b/qt6/gen_qobject.h
@@ -48,7 +48,7 @@ typedef struct QTimerEvent QTimerEvent;
 typedef struct QVariant QVariant;
 #endif
 
-QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self);
+const QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self);
 void QObjectData_delete(QObjectData* self);
 
 QObject* QObject_new();

The return type is now const instead of the inverse. This worked for a local build of the examples against 6.9.0 on Arch. No other issues were encountered with the examples.

@rcalixte
Copy link
Contributor

Feel free to assign this to me if you haven't started yet. I think I can get it done in an hour or two. Fortunately, this doesn't intersect with the existing const/non-const change. Once we start getting versions built against newer Qt bases, this should mitigate the issues. (And hopefully we don't need to deal with the intersection of these two... ever. 😅)

@mappu
Copy link
Owner

mappu commented Apr 11, 2025

@emad-elsaid Can you please try go get github.com/mappu/miqt@master and confirm if that resolves the issue for you?

@emad-elsaid
Copy link
Author

Thanks, I'll do that in the end of the day when I have access the machine

@emad-elsaid
Copy link
Author

@mappu I'm getting a different error:

time go run  -ldflags '-s -w' .
# github.com/mappu/miqt/qt6/webchannel
gen_qqmlwebchannel.cpp:7:10: fatal error: QQmlWebChannel: No such file or directory
    7 | #include <QQmlWebChannel>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
# github.com/mappu/miqt/qt6/network
gen_qsctpserver.cpp:6:10: fatal error: QSctpServer: No such file or directory
    6 | #include <QSctpServer>
      |          ^~~~~~~~~~~~~
compilation terminated.

real	19m8.897s
user	35m40.260s
sys	1m12.160s

@rcalixte
Copy link
Contributor

rcalixte commented Apr 11, 2025

@mappu I'm getting a different error:

This is something with how Qt 6 is packaged for Arch. See #150 for more details. There is a workaround for the QQmlWebChannel header but QSctpServer and QSctpSocket are missing from the Qt 6 Network packages for Arch. This seems to be intentional but maybe check with upstream to be sure?

It would be great for Arch users if there could be a fix either here or upstream but this would be Arch-specific and not Linux-specific which makes a potential implementation more interesting.

@mappu mappu reopened this Apr 11, 2025
@mappu
Copy link
Owner

mappu commented Apr 12, 2025

Seems like these classes have been missing in Arch Linux since at least 2019.

A workaround would be to have genbindings move the two Sctp classes to a new subpackage, like was done with cbor. Probably only QSctpServer / QSctpClient are affected.

FYI @5k3105

@rcalixte
Copy link
Contributor

rcalixte commented Apr 12, 2025

Should this issue be closed in favor of #150 or a new issue? Could it be tied into #185?

A workaround would be to have genbindings move the two Sctp classes to a new subpackage, like was done with cbor. Probably only QSctpServer / QSctpClient are affected.

These headers are also missing from FreeBSD just the same. I haven't looked into why yet.

@mappu
Copy link
Owner

mappu commented Apr 12, 2025

See also #151 / #159 for another (different) part of QNetwork that is not present in some distributions.

@emad-elsaid
Copy link
Author

emad-elsaid commented Apr 13, 2025

I see #199 is merged as a fix, but pulling master and retrying produce the same error, I made sure it's using the correct commit from go.sum

require github.com/mappu/miqt v0.9.1-0.20250412232210-862bd100f4be

I'm in no rush for a solution, just making sure we're aware it's not solved yet.

@mappu
Copy link
Owner

mappu commented Apr 14, 2025

#199 is not merged yet. To try it early, run go get github.com/mappu/miqt@miqt-archlinux-qt69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants