Below is the related instruction in qt.
QDataStream & operator<< ( QDataStream & s, const QValueList<T> & l )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Writes a list, l, to the stream s. The type T stored in the list must implement the streaming operator.
QDataStream & operator>> ( QDataStream & s, QValueList<T> & l )
Reads a list, l, from the stream s. The type T stored in the list must implement the streaming operator.
I have realize >> operator in my "T", as below:
class CSysAlarm
{
public:
CSysAlarm(ENUM_INFO_TYPE infoType=COS_INFO);
~CSysAlarm();
QDataStream& operator <<( QDataStream& stream );
// Attributes
public:
ENUM_INFO_TYPE m_enumInfoType;
bool m_bIfAlarm;
uint m_dwAlarmTimes;
bool m_bAutoPrint;
bool m_bIfPop;
bool m_bIfLoop;
bool m_bAllInfo;
public:
};
class CSysAlarm
{
public:
CSysAlarm(ENUM_INFO_TYPE infoType=COS_INFO);
~CSysAlarm();
QDataStream& operator <<( QDataStream& stream );
// Attributes
public:
ENUM_INFO_TYPE m_enumInfoType;
bool m_bIfAlarm;
uint m_dwAlarmTimes;
bool m_bAutoPrint;
bool m_bIfPop;
bool m_bIfLoop;
bool m_bAllInfo;
QString m_strPathFile;
public:
};
To copy to clipboard, switch view to plain text mode
And other code:
QFile file( "hmiset.bin" );
if(file.open(IO_WriteOnly )==false)
return;
QFile file( "hmiset.bin" );
if(file.open(IO_WriteOnly )==false)
return;
QDataStream stream( &file );
To copy to clipboard, switch view to plain text mode
How can I do this as title? thanks!
Bookmarks