[Interest] Qt6: QShared<const TYPE> is not supported in signals if TYPE is an QObject?

Alexander Dyagilev alervdvcw at gmail.com
Wed May 25 01:06:23 CEST 2022


Just noticed MinGW config was active. Here is the output for MSVC2019 
config:

02:05:06: Running steps for project untitled...
02:05:06: Configuration unchanged, skipping qmake step.
02:05:06: Starting: "D:\Qt\Tools\QtCreator\bin\jom\jom.exe"
     D:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug
     cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline 
-Zc:strictStrings -Zc:throwingNew -permissive- -Zc:__cplusplus 
-Zc:externConstexpr -Zi -MDd -std:c++17 -utf-8 -W3 -w34100 -w34189 
-w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc 
/Fddebug\untitled.vc.pdb -DUNICODE -D_UNICODE -DWIN32 
-D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_QML_DEBUG 
-DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\untitled -I. 
-ID:\Qt\6.2.4\msvc2019_64\include 
-ID:\Qt\6.2.4\msvc2019_64\include\QtWidgets 
-ID:\Qt\6.2.4\msvc2019_64\include\QtGui 
-ID:\Qt\6.2.4\msvc2019_64\include\QtCore -Idebug -I. -I/include 
-ID:\Qt\6.2.4\msvc2019_64\mkspecs\win32-msvc -Fodebug\ 
@C:\Users\alexa\AppData\Local\Temp\moc_a.obj.16220.32.jom
moc_a.cpp
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1196): error C2440: 
'return': cannot convert from 'T *' to 'QObject *'
         with
         [
             T=const B
         ]
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1196): note: 
Conversion loses qualifiers
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1195): note: while 
compiling class template member function 'QObject 
*QtPrivate::QSmartPointerConvertFunctor<QSharedPointer<const 
B>>::operator ()(const SmartPointer &) const'
         with
         [
             SmartPointer=QSharedPointer<const B>
         ]
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(613): note: see 
reference to function template instantiation 'QObject 
*QtPrivate::QSmartPointerConvertFunctor<QSharedPointer<const 
B>>::operator ()(const SmartPointer &) const' being compiled
         with
         [
             SmartPointer=QSharedPointer<const B>
         ]
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1579): note: see 
reference to class template instantiation 
'QtPrivate::QSmartPointerConvertFunctor<QSharedPointer<const B>>' being 
compiled
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1579): note: while 
compiling class template member function 'bool 
QtPrivate::MetaTypeSmartPointerHelper<T,void>::registerConverter(void)'
         with
         [
             T=QSharedPointer<const B>
         ]
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1233): note: see 
reference to function template instantiation 'bool 
QtPrivate::MetaTypeSmartPointerHelper<T,void>::registerConverter(void)' 
being compiled
         with
         [
             T=QSharedPointer<const B>
         ]
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1233): note: see 
reference to class template instantiation 
'QtPrivate::MetaTypeSmartPointerHelper<T,void>' being compiled
         with
         [
             T=QSharedPointer<const B>
         ]
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1579): note: see 
reference to function template instantiation 'int 
qRegisterNormalizedMetaType<QSharedPointer<const B>>(const QByteArray 
&)' being compiled
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1579): note: while 
compiling class template member function 'int 
QtPrivate::SharedPointerMetaTypeIdHelper<QSharedPointer<const 
B>,true>::qt_metatype_id(void)'
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1133): note: see 
reference to function template instantiation 'int 
QtPrivate::SharedPointerMetaTypeIdHelper<QSharedPointer<const 
B>,true>::qt_metatype_id(void)' being compiled
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1579): note: see 
reference to class template instantiation 
'QtPrivate::SharedPointerMetaTypeIdHelper<QSharedPointer<const B>,true>' 
being compiled
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(1132): note: see 
reference to class template instantiation 'QMetaTypeId<T>' being compiled
         with
         [
             T=Ty
         ]
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(2317): note: see 
reference to class template instantiation 'QMetaTypeId2<T>' being compiled
         with
         [
             T=Ty
         ]
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(2439): note: see 
reference to class template instantiation 
'QtPrivate::QMetaTypeInterfaceWrapper<Ty>' being compiled
D:\Qt\6.2.4\msvc2019_64\include\QtCore/qmetatype.h(2482): note: see 
reference to function template instantiation 'const 
QtPrivate::QMetaTypeInterface 
*QtPrivate::qTryMetaTypeInterfaceForType<Unique,QtPrivate::TypeAndForceComplete<QSharedPointer<const 
B>,std::false_type>>(void)' being compiled
         with
         [
             Unique=qt_meta_stringdata_A_t
         ]
debug\moc_a.cpp(106): note: see reference to variable template 'const 
QtPrivate::QMetaTypeInterface *const 
qt_incomplete_metaTypeArray<qt_meta_stringdata_A_t,QtPrivate::TypeAndForceComplete<A,std::integral_constant<bool,1> 
 >,QtPrivate::TypeAndForceComplete<void,std::integral_constant<bool,0> 
 >,QtPrivate::TypeAndForceComplete<QSharedPointer<C const > const 
&,std::integral_constant<bool,0> 
 >,QtPrivate::TypeAndForceComplete<void,std::integral_constant<bool,0> 
 >,QtPrivate::TypeAndForceComplete<QSharedPointer<B const 
 >,std::integral_constant<bool,0> > >[5]' being compiled
jom: C:\Users\alexa\Documents\Qt 
Creator\build-untitled-Desktop_Qt_6_2_4_MSVC2019_64bit-Debug\Makefile.Debug 
[debug\moc_a.obj] Error 2
jom: C:\Users\alexa\Documents\Qt 
Creator\build-untitled-Desktop_Qt_6_2_4_MSVC2019_64bit-Debug\Makefile 
[debug] Error 2
02:05:08: The process "D:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited 
with code 2.
Error while building/deploying project untitled (kit: Desktop Qt 6.2.4 
MSVC2019 64bit)
When executing step "Make"
02:05:08: Elapsed time: 00:02.

On 5/25/2022 2:02 AM, Alexander Dyagilev wrote:
> Hello,
>
> On 5/20/2022 6:45 PM, Thiago Macieira wrote:
>> Please share the error message.
>
> 01:58:24: Running steps for project untitled...
> 01:58:24: Configuration unchanged, skipping qmake step.
> 01:58:24: Starting: "D:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j16
> D:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug
> mingw32-make[1]: Entering directory 'C:/Users/alexa/Documents/Qt 
> Creator/build-untitled-Desktop_Qt_6_2_4_MinGW_64_bit-Debug'
> g++ -c -fno-keep-inline-dllexport -g -std=gnu++1z -Wall -Wextra 
> -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 
> -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB 
> -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../untitled -I. 
> -ID:/Qt/6.2.4/mingw_64/include 
> -ID:/Qt/6.2.4/mingw_64/include/QtWidgets 
> -ID:/Qt/6.2.4/mingw_64/include/QtGui 
> -ID:/Qt/6.2.4/mingw_64/include/QtCore -Idebug -I. -I/include 
> -ID:/Qt/6.2.4/mingw_64/mkspecs/win32-g++  -o debug\moc_a.o 
> debug\moc_a.cpp
> In file included from D:/Qt/6.2.4/mingw_64/include/QtCore/qobject.h:54,
>                  from D:/Qt/6.2.4/mingw_64/include/QtCore/QObject:1,
>                  from debug\../../untitled/a.h:3,
>                  from debug\moc_a.cpp:10:
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h: In instantiation of 
> 'QObject* 
> QtPrivate::QSmartPointerConvertFunctor<SmartPointer>::operator()(const 
> SmartPointer&) const [with SmartPointer = QSharedPointer<const B>]':
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:613:26:   required 
> from 'static bool QMetaType::registerConverter(UnaryFunction) [with 
> From = QSharedPointer<const B>; To = QObject*; UnaryFunction = 
> QtPrivate::QSmartPointerConvertFunctor<QSharedPointer<const B> >]'
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:1579:1:   required 
> from 'static bool 
> QtPrivate::MetaTypeSmartPointerHelper<QSharedPointer<T>, typename 
> std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value>::type>::registerConverter() 
> [with T = const B]'
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:1233:64: required from 
> 'int qRegisterNormalizedMetaType(const QByteArray&) [with T = 
> QSharedPointer<const B>]'
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:1579:1:   required 
> from 'static int 
> QtPrivate::SharedPointerMetaTypeIdHelper<QSharedPointer<T>, 
> true>::qt_metatype_id() [with T = const B]'
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:1133:89: required from 
> 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = 
> QSharedPointer<const B>]'
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:2293:27: required from 
> 'static constexpr void (* 
> QtPrivate::QMetaTypeForType<S>::getLegacyRegister())() [with S = 
> QSharedPointer<const B>; 
> QtPrivate::QMetaTypeInterface::LegacyRegisterOp = void (*)()]'
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:2329:70: required from 
> 'constexpr const QtPrivate::QMetaTypeInterface 
> QtPrivate::QMetaTypeInterfaceWrapper<QSharedPointer<const B> >::metaType'
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:2439:16: required from 
> 'constexpr const QtPrivate::QMetaTypeInterface* 
> QtPrivate::qTryMetaTypeInterfaceForType() [with Unique = 
> qt_meta_stringdata_A_t; TypeCompletePair = 
> QtPrivate::TypeAndForceComplete<QSharedPointer<const B>, 
> std::integral_constant<bool, false> >]'
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:2483:55: required from 
> 'constexpr const QtPrivate::QMetaTypeInterface* const 
> qt_incomplete_metaTypeArray [5]<qt_meta_stringdata_A_t, 
> QtPrivate::TypeAndForceComplete<A, std::integral_constant<bool, true> 
> >, QtPrivate::TypeAndForceComplete<void, std::integral_constant<bool, 
> false> >, QtPrivate::TypeAndForceComplete<const QSharedPointer<const 
> C>&, std::integral_constant<bool, false> >, 
> QtPrivate::TypeAndForceComplete<void, std::integral_constant<bool, 
> false> >, QtPrivate::TypeAndForceComplete<QSharedPointer<const B>, 
> std::integral_constant<bool, false> > >'
> debug\moc_a.cpp:106:1:   required from here
> D:/Qt/6.2.4/mingw_64/include/QtCore/qmetatype.h:1196:32: error: 
> invalid conversion from 'const QObject*' to 'QObject*' [-fpermissive]
>  1196 |             return p.operator->();
>       |                    ~~~~~~~~~~~~^~
>       |                                |
>       |                                const QObject*
> mingw32-make[1]: Leaving directory 'C:/Users/alexa/Documents/Qt 
> Creator/build-untitled-Desktop_Qt_6_2_4_MinGW_64_bit-Debug'
> mingw32-make[1]: *** [Makefile.Debug:913: debug/moc_a.o] Error 1
> mingw32-make: *** [Makefile:45: debug] Error 2
> 01:58:26: The process "D:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" 
> exited with code 2.
> Error while building/deploying project untitled (kit: Desktop Qt 6.2.4 
> MinGW 64-bit)
> When executing step "Make"
> 01:58:26: Elapsed time: 00:02.
>
>> And please use an email client that knows how to paste spaces. Your 
>> code is
>> unreadable:
>
> Hmm... Is Mozilla Thunderbird really that bad? What email client would 
> you recommend to use instead?
>
>


More information about the Interest mailing list