Hi to all,
reading the documentation seems easy but I can not convert a QByteArray to a QVariantList.
I know that first I have to convert it to a QVariant and then I append to a QVariantList.
I wrote this code:
in my class declaration I have
class UserData
{
public:
QByteArray& fingerData(){ return m_fpData; }
..more code..
}
class UserData
{
public:
QByteArray m_fpData;//352bytes
QByteArray& fingerData(){ return m_fpData; }
..more code..
}
To copy to clipboard, switch view to plain text mode
and in a method of another class I have
bool Device::registerNewUser(UserData* user)
{
QList<QVariant> paramList;
//cardId
//fp data
QByteArray& b = user->fingerData(); //I get the reference to the bytearray
v.setValue(b); //I add it to a QVariant
QVariantList fingerData;
fingerData.append(v); //and finally to a QVarianList
...more code...
}
bool Device::registerNewUser(UserData* user)
{
QList<QVariant> paramList;
//cardId
QString cardId = QString::number( user->cardId(), 10 );
//fp data
QByteArray& b = user->fingerData(); //I get the reference to the bytearray
QVariant v;
v.setValue(b); //I add it to a QVariant
QVariantList fingerData;
fingerData.append(v); //and finally to a QVarianList
...more code...
}
To copy to clipboard, switch view to plain text mode
Unfortunately I get invalid pointer of the QVariant. This is strange to me as from documentation of QVariant a QVariant accept a reference to a QByteArray as constructor:
Constructs a new variant with a bytearray value, val.
QVariant::QVariant ( const QByteArray & val )
Constructs a new variant with a bytearray value, val.
To copy to clipboard, switch view to plain text mode
So I don't know how to solve my problem
Bookmarks