C++ QT5.5中qDebug()的新QFlags帮助程序存在问题
我有以下代码C++ QT5.5中qDebug()的新QFlags帮助程序存在问题,c++,qt,qt5.5,C++,Qt,Qt5.5,我有以下代码 #include <QDebug> //Needed for other stuff!! #include <QDataStream> class TestClass { public: class SubClass { public: QString a; int b; /* //Needed for QDataStream but not relevant for th
#include <QDebug> //Needed for other stuff!!
#include <QDataStream>
class TestClass {
public:
class SubClass {
public:
QString a;
int b;
/*
//Needed for QDataStream but not relevant for the generated error
friend QDataStream& operator<<(QDataStream& os, SubClass const& f)
{
os << f.a;
os << f.b;
return os;
}
friend QDataStream& operator>>(QDataStream& is, SubClass& f)
{
is >> f.a;
is >> f.b;
return is;
}*/
friend QDataStream& operator<< <SubClass>(QDataStream&, QList<SubClass> const&);
friend QDataStream& operator>> <SubClass>(QDataStream&, QList<SubClass>&);
};
};
#包括//其他东西需要的!!
#包括
类TestClass{
公众:
类子类{
公众:
QString a;
int b;
/*
//QDataStream需要,但与生成的错误无关
friend QDataStream&运营商f.a;
is>>f.b;
回报是;
}*/
friend QDataStream&operator>(QDataStream&,QList&);
};
};
使用qt5.5编译它时会出现以下错误:
/usr/include/qt/QtCore/qflags.h:88: error: invalid application of 'sizeof' to an incomplete type 'TestClass::SubClass'
Q_STATIC_ASSERT_X((sizeof(Enum) <= sizeof(int)),
^~~~~~~~~~~~
/usr/include/qt/QtCore/qtypetraits.h:478: error: 'TestClass::SubClass' is an incomplete type
: integral_constant<bool, (T(0) < T(-1))> {};
^
/usr/include/qt/QtCore/qdebug.h:279: in instantiation of template class 'QtPrivate::IsQEnumHelper<QFlags<TestClass::SubClass> >' requested here
QtPrivate::IsQEnumHelper<T>::Value || QtPrivate::IsQEnumHelper<QFlags<T> >::Value,
^
main.cpp:25: while substituting explicitly-specified template arguments into function template 'operator<<'
friend QDataStream& operator<< <SubClass>(QDataStream&, QList<SubClass> const&);
^
/usr/include/qt/QtCore/qflags.h:88:错误:“sizeof”对不完整类型“TestClass::SubClass”的应用无效
Q_STATIC_ASSERT_X((sizeof(Enum)以下(简化代码)生成相同的错误
#include <QDebug> //Needed to cause the error
class TestClassA {};
class TestClassB {};
template <typename T>
TestClassA& operator<<(TestClassA& s, T& l) {
Q_UNUSED(l)
return s;
}
template TestClassA& operator<< <TestClassB>(TestClassA& s, TestClassB& l);
#包含//导致错误所需的
类TestClassA{};
类TestClassB{};
模板
TestClassA&operator以下(简化代码)生成相同的错误
#include <QDebug> //Needed to cause the error
class TestClassA {};
class TestClassB {};
template <typename T>
TestClassA& operator<<(TestClassA& s, T& l) {
Q_UNUSED(l)
return s;
}
template TestClassA& operator<< <TestClassB>(TestClassA& s, TestClassB& l);
#包含//导致错误所需的
类TestClassA{};
类TestClassB{};
模板
TestClassA&运算符
#include <QDebug> //Needed to cause the error
class TestClassA {};
class TestClassB {};
template <typename T>
TestClassA& operator<<(TestClassA& s, T& l) {
Q_UNUSED(l)
return s;
}
template TestClassA& operator<< <TestClassB>(TestClassA& s, TestClassB& l);