// 结构体定义
struct MyStruct
{
QString name;
int point[2];
};
// 重载结构体<<符合
std::ostream & operator<<(std::ostream & os, const MyStruct & c)
{
os << c.name.toStdString();
return os;
}
QDebug & operator<<(QDebug & os, const MyStruct & c)
{
os << c.name << c.point[0] << c.point[1];
return os;
}
// 使用 输出结构体
MyStruct my;
my.name = "name";
my.point[0] = 4;
my.point[1] = 5;
qDebug() << my;