Qt 前置声明 在 QList 中的 qtypeinfo.h invalid application of 'sizeof' to incomplete type qlist.h:496: error

本文介绍了一个关于QtFtp工程中使用QList<QUrlInfo>变量导致的编译错误问题及解决方案。错误发生在qtypeinfo.h和qlist.h文件中,涉及到QUrlInfo类型的不完整定义。通过删除前置声明并包含&qurlinfo.h;头文件解决了问题。

在下载的QtFtp工程的examples中,添加了QList<QUrlInfo>变量,结果导致了下面的两处编译错误。

H:\QT\qt-src-5.9.2\qtbase\src\corelib\global\qtypeinfo.h:67: error: invalid application of 'sizeof' to incomplete type 'QUrlInfo'

         isLarge = (sizeof(T)>sizeof(void*)),


H:\QT\qt-src-5.9.2\qtbase\src\corelib\tools\qlist.h:496: error: invalid use of incomplete type 'class QUrlInfo'
         while (from != to) --to, reinterpret_cast<T*>(to)->~T();


在添加这个之前是没问题。QUrlInfo在FtpWindow.h有一个前置声明。


解决方法:把前置声明删除,添加#include <qurlinfo.h>就可以了。

D:\Tool\Qt5.12.12\5.12.12\mingw73_64\include\QtCore\qtypeinfo.h:215: error: invalid application of 'sizeof' to incomplete type 'QMap<QString, QString>' In file included from D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qglobal.h:1204:0, from D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qnamespace.h:43, from D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qobjectdefs.h:48, from D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qobject.h:46, from D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/QObject:1, from GeneratedFiles\moc\../../paramejson.h:4, from GeneratedFiles\moc\moc_paramejson.cpp:9: D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qtypeinfo.h: In instantiation of 'class QTypeInfo<QMap<QString, QString> >': D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qlist.h:496:31: required from 'void QList<T>::node_destruct(QList<T>::Node*, QList<T>::Node*) [with T = QMap<QString, QString>]' D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qlist.h:868:18: required from 'void QList<T>::dealloc(QListData::Data*) [with T = QMap<QString, QString>]' D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qlist.h:830:16: required from 'QList<T>::~QList() [with T = QMap<QString, QString>]' GeneratedFiles\moc\../../paramejson.h:9:8: required from 'void QList<T>::node_destruct(QList<T>::Node*, QList<T>::Node*) [with T = NodeData]' D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qlist.h:868:18: required from 'void QList<T>::dealloc(QListData::Data*) [with T = NodeData]' D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qlist.h:830:16: required from 'QList<T>::~QList() [with T = NodeData]' GeneratedFiles\moc\../../paramejson.h:16:7: required from here D:/Tool/Qt5.12.12/5.12.12/mingw73_64/include/QtCore/qtypeinfo.h:215:26: error: invalid application of 'sizeof' to incomplete type 'QMap<QString, QString>' isLarge = (sizeof
09-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值