Results 1 to 8 of 8

Thread: strange conversion!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default strange conversion!

    hi

    this is code:

    Qt Code:
    1. void test(void)
    2. {
    3. QByteArray _qba;
    4. _qba.clear();
    5. int index=0;
    6. unsigned char hi,lo;
    7. unsigned int uin,u32r;
    8. bool br;
    9. for(int i=0; i<dock->tableWidget->rowCount(); i++){
    10. u32r=dock->tableWidget->item(i,2)->text().toUInt(&br);
    11. qDebug()<<"["<<u32r<<"]";
    12. if(!br)return;
    13. hi=(unsigned char)(u32r/ 256);
    14. lo=(unsigned char)(u32r % 256);
    15. _qba.append(hi);
    16. _qba.append(lo);
    17. qDebug()<<"("<<(unsigned char)_qba.data()[index]<<","<<(unsigned char)_qba.data()[index+1]<<")";
    18. uin=(unsigned int)(_qba.data()[index]*256+_qba.data()[index+1]);
    19. index+=2;
    20. uin &= 0x0000ffff;
    21. qDebug()<<uin;
    22. qDebug()<<"{"<<hi*256+lo<<"}";
    23. }
    24. }
    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!
    Last edited by wysota; 14th June 2010 at 10:10. Reason: changed [qtclass] to [code]

Similar Threads

  1. Hex Conversion
    By umulingu in forum Newbie
    Replies: 5
    Last Post: 5th March 2010, 18:07
  2. difficulty in conversion
    By mohanakrishnan in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2009, 10:31
  3. Pixmap conversion
    By MrShahi in forum Qt Programming
    Replies: 7
    Last Post: 26th June 2008, 10:03
  4. Reg - Conversion of Qt3 to Qt4
    By suresh in forum Qt Programming
    Replies: 10
    Last Post: 28th August 2006, 23:10
  5. conversion of color
    By Stephano in forum Qt Programming
    Replies: 5
    Last Post: 22nd May 2006, 11:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.