enum QVariant::Type is obsolete?
-
- I need to determine the types of the columns returned from a
QSqlQuery. - I can access the column definitions via
QSqlQuery::record()::field(int). This returns aQSqlField. - http://doc.qt.io/qt-5/qsqlfield.html#type gives me
QVariant::Type QSqlField::type() const. - The return type of
QVariant::Typeis documented at http://doc.qt.io/qt-5/qvariant-obsolete.html#Type-enum under title "Obsolete Members for QVariant"
If it is obsolete, how come
QSqlField::type()returns it? What should I be using instead to achieve this? - I need to determine the types of the columns returned from a
-
- I need to determine the types of the columns returned from a
QSqlQuery. - I can access the column definitions via
QSqlQuery::record()::field(int). This returns aQSqlField. - http://doc.qt.io/qt-5/qsqlfield.html#type gives me
QVariant::Type QSqlField::type() const. - The return type of
QVariant::Typeis documented at http://doc.qt.io/qt-5/qvariant-obsolete.html#Type-enum under title "Obsolete Members for QVariant"
If it is obsolete, how come
QSqlField::type()returns it? What should I be using instead to achieve this?@JonB said in enum QVariant::Type is obsolete?:
What should I be using instead to achieve this?
There's some info at the documentation for QVariant::type().
QVariant::Typehas been superseded byQMetaType::Type.The integral values of the two enums are interchangeable, so you can safely reinterpret the return value of
QSqlField::type()as aQMetaType::Type. You can also passQMetaType::Typevalues intoQSqlField::setType().If it is obsolete, how come
QSqlField::type()returns it?To maintain backwards-compatibility.
I'd imagine that in Qt 6, all instances of
QVariant::Typewill be fully replaced byQMetaType::Type. - I need to determine the types of the columns returned from a
-
- I need to determine the types of the columns returned from a
QSqlQuery. - I can access the column definitions via
QSqlQuery::record()::field(int). This returns aQSqlField. - http://doc.qt.io/qt-5/qsqlfield.html#type gives me
QVariant::Type QSqlField::type() const. - The return type of
QVariant::Typeis documented at http://doc.qt.io/qt-5/qvariant-obsolete.html#Type-enum under title "Obsolete Members for QVariant"
If it is obsolete, how come
QSqlField::type()returns it? What should I be using instead to achieve this? - I need to determine the types of the columns returned from a
-
@JonB said in enum QVariant::Type is obsolete?:
What should I be using instead to achieve this?
There's some info at the documentation for QVariant::type().
QVariant::Typehas been superseded byQMetaType::Type.The integral values of the two enums are interchangeable, so you can safely reinterpret the return value of
QSqlField::type()as aQMetaType::Type. You can also passQMetaType::Typevalues intoQSqlField::setType().If it is obsolete, how come
QSqlField::type()returns it?To maintain backwards-compatibility.
I'd imagine that in Qt 6, all instances of
QVariant::Typewill be fully replaced byQMetaType::Type.@JKSH
Thanks for that. I did not come across that link, if you follow the links through the manual as I said I did you don't hit http://doc.qt.io/qt-5/qvariant.html#type. I'm good to go on that.Are you happy with the way I'm saying I determine the "type" for a column returned from the database? I need to know that for arbitrary formatting etc. rules, e.g. suitable column alignment in a table.
-
@JKSH
Thanks for that. I did not come across that link, if you follow the links through the manual as I said I did you don't hit http://doc.qt.io/qt-5/qvariant.html#type. I'm good to go on that.Are you happy with the way I'm saying I determine the "type" for a column returned from the database? I need to know that for arbitrary formatting etc. rules, e.g. suitable column alignment in a table.
@JonB said in enum QVariant::Type is obsolete?:
@JKSH
Thanks for that. I did not come across that link, if you follow the links through the manual as I said I did you don't hit http://doc.qt.io/qt-5/qvariant.html#type. I'm good to go on that.You're welcome :) Looks like a bug/oversight in the documentation generator: https://bugreports.qt.io/browse/QTBUG-68327
Are you happy with the way I'm saying I determine the "type" for a column returned from the database? I need to know that for arbitrary formatting etc. rules, e.g. suitable column alignment in a table.
Yes, I think that's exactly how the designers of
QSqlFieldintended it to be used.