hi
this is code:
void test(void)
{
_qba.clear();
int index=0;
unsigned char hi,lo;
unsigned int uin,u32r;
bool br;
for(int i=0; i<dock->tableWidget->rowCount(); i++){
u32r=dock->tableWidget->item(i,2)->text().toUInt(&br);
qDebug()<<"["<<u32r<<"]";
if(!br)return;
hi=(unsigned char)(u32r/ 256);
lo=(unsigned char)(u32r % 256);
_qba.append(hi);
_qba.append(lo);
qDebug()<<"("<<(unsigned char)_qba.data()[index]<<","<<(unsigned char)_qba.data()[index+1]<<")";
uin=(unsigned int)(_qba.data()[index]*256+_qba.data()[index+1]);
index+=2;
uin &= 0x0000ffff;
qDebug()<<uin;
qDebug()<<"{"<<hi*256+lo<<"}";
}
}
void test(void)
{
QByteArray _qba;
_qba.clear();
int index=0;
unsigned char hi,lo;
unsigned int uin,u32r;
bool br;
for(int i=0; i<dock->tableWidget->rowCount(); i++){
u32r=dock->tableWidget->item(i,2)->text().toUInt(&br);
qDebug()<<"["<<u32r<<"]";
if(!br)return;
hi=(unsigned char)(u32r/ 256);
lo=(unsigned char)(u32r % 256);
_qba.append(hi);
_qba.append(lo);
qDebug()<<"("<<(unsigned char)_qba.data()[index]<<","<<(unsigned char)_qba.data()[index+1]<<")";
uin=(unsigned int)(_qba.data()[index]*256+_qba.data()[index+1]);
index+=2;
uin &= 0x0000ffff;
qDebug()<<uin;
qDebug()<<"{"<<hi*256+lo<<"}";
}
}
To copy to clipboard, switch view to plain text mode
this is debug:
[ 100 ]
( 0 , 100 )
100
{ 100 }
[ 350 ]
( 1 , 94 )
350
{ 350 }
[ 1400 ]
( 5 , 120 )
1400
{ 1400 }
[ 36344 ]
( 141 , 248 )
36088
{ 36344 }
[ 62000 ]
( 242 , 48 )
62000
{ 62000 }
[ 58344 ]
( 227 , 232 )
58088
{ 58344 }
[ 0 ]
( 0 , 0 )
0
{ 0 }
why there is strange conversion for some ones:
[ 36344 ]
( 141 , 248 )
36088
{ 36344 }
also, using qDebug()<<(int)uin; produce same result!
Bookmarks