Skip to content

Commit 14e7ef7

Browse files
committed
https://github.com/QtExcel/QXlsx/issues/171
1 parent 560e52d commit 14e7ef7

File tree

1 file changed

+37
-16
lines changed

1 file changed

+37
-16
lines changed

QXlsx/source/xlsxcell.cpp

+37-16
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,43 @@ QVariant Cell::readValue() const
130130
return QVariant();
131131
}
132132

133-
if ( vDT.type() == QVariant::DateTime )
134-
{
135-
ret = vDT;
136-
}
137-
else if ( vDT.type() == QVariant::Date )
138-
{
139-
ret = vDT;
140-
}
141-
else if ( vDT.type() == QVariant::Time )
142-
{
143-
ret = vDT;
144-
}
145-
else
146-
{
147-
return QVariant();
148-
}
133+
// https://github.com/QtExcel/QXlsx/issues/171
134+
// https://www.qt.io/blog/whats-new-in-qmetatype-qvariant
135+
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
136+
if ( vDT.metaType().id() == QMetaType::QDateTime )
137+
{
138+
ret = vDT;
139+
}
140+
else if ( vDT.metaType().id() == QMetaType::QDate )
141+
{
142+
ret = vDT;
143+
}
144+
else if ( vDT.metaType().id() == QMetaType::QTime )
145+
{
146+
ret = vDT;
147+
}
148+
else
149+
{
150+
return QVariant();
151+
}
152+
#else
153+
if ( vDT.type() == QVariant::DateTime )
154+
{
155+
ret = vDT;
156+
}
157+
else if ( vDT.type() == QVariant::Date )
158+
{
159+
ret = vDT;
160+
}
161+
else if ( vDT.type() == QVariant::Time )
162+
{
163+
ret = vDT;
164+
}
165+
else
166+
{
167+
return QVariant();
168+
}
169+
#endif
149170

150171
// QDateTime dt = dateTime();
151172
// ret = dt;

0 commit comments

Comments
 (0)