[Interest] [Qt6] QML automatic type registration in a (shared) library

Ulf Hermann ulf.hermann at qt.io
Fri Jan 14 22:58:05 CET 2022


> In my case to make 
> extra sure I exported a dummy global symbol from the dll. If I don't do 
> anything with it - nothing works. If I print it with qDebug() in the 
> application code, the library is loaded and registration code and all 
> works just as expected.

Indeed. And instead of the dummy symbol you can just use the existing 
type registration function for that. As you've found out, "just store 
it" is not enough. You have to "do" something with it. Sorry for being 
inaccurate there.

The way we work around the issue in the generated plugin code is storing 
it in a volatile pointer. That's terrible and also not guaranteed to 
work, but it works in practice on all compilers we support. If you 
figure out a better way, please let me know.

best regards,
Ulf


More information about the Interest mailing list