Results 1 to 12 of 12

Thread: Restrict specified number of charecters in each row of Sqlite Db

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Restrict specified number of charecters in each row of Sqlite Db

    I cannot tell you what the logic of your program is or should be. The buffer will be emptied of whole records by the while loop which will exit if there is not a whole record in the buffer. Presumably, when more data is added to the buffer you will call this code again. If no more data is appended to the buffer then more records will never be written to the database.

    If you want to throw away the content of the buffer the the clear() method is good for that.

  2. The following user says thank you to ChrisW67 for this useful post:

    nagabathula (3rd January 2011)

  3. #2
    Join Date
    Nov 2010
    Posts
    100
    Qt products
    Qt3 Qt4
    Thanks
    38
    Thanked 1 Time in 1 Post

    Default Re: Restrict specified number of charecters in each row of Sqlite Db

    Hello sir i have one more doubt .. I am actually doing this to save the data into the rsdata from rs232 port
    Qt Code:
    1. QByteArray rsdata = (QByteArray::fromRawData(buff,numBytes));
    To copy to clipboard, switch view to plain text mode 
    but i read the detail description of
    QByteArray QByteArray::fromRawData ( const char * data, int size )
    Constructs a QByteArray that uses the first size characters in the array data. The bytes in data are not copied. The caller must be able to guarantee that data will not be deleted or modified as long as the QByteArray (or an unmodified copy of it) exists.
    Any attempts to modify the QByteArray or copies of it will cause it to create a deep copy of the data, ensuring that the raw data isn't modified.
    but i am doing some bitwise shifting and aligining of the data so can it be the reason i am losing data sir, ?

    I tried it this way i though i will append the data into an QByteArray rsdata; is this right sir it sud append the data in buff but i am not seeing the right data.
    Qt Code:
    1. rsdata.append((QByteArray::fromRawData(buff,numBytes)).toHex());
    To copy to clipboard, switch view to plain text mode 


    thank you

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Restrict specified number of charecters in each row of Sqlite Db

    I cannot tell you why you are losing data.

    It is easy enough to do a simple experiment to find out if the sort of manipulations you do will cause a deep copy:
    Qt Code:
    1. #include <QtCore>
    2. #include <QDebug>
    3.  
    4. int main(int argc, char **argv)
    5. {
    6. QCoreApplication app(argc, argv);
    7.  
    8. char buf[] = "....";
    9. QByteArray a = QByteArray::fromRawData(buf, 4);
    10. QByteArray b = a; // shallow copy of a
    11. qDebug() << buf << a << b; // all point to buf and show same data
    12.  
    13. buf[0] = 'X'; // modify original buffer directly
    14. qDebug() << buf << a << b; // all changed because the share the buffer
    15.  
    16. b[0] = 'Y'; // change using the byte array interface causes deep copy
    17. qDebug() << buf << a << b; // only b changed after deep-copy
    18. }
    To copy to clipboard, switch view to plain text mode 
    Output:
    Qt Code:
    1. .... "...." "...."
    2. X... "X..." "X..."
    3. X... "X..." "Y..."
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to ChrisW67 for this useful post:

    nagabathula (5th January 2011)

Similar Threads

  1. Replies: 4
    Last Post: 16th October 2015, 16:13
  2. QTableView restrict ScrollArea
    By hoshy in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2009, 09:54
  3. Can we restrict the movement of a Qt Window?
    By Frank J. Lhota in forum Qt Programming
    Replies: 4
    Last Post: 21st October 2008, 21:34
  4. How to restrict autodelete in Qt?
    By vql in forum Qt Programming
    Replies: 1
    Last Post: 23rd March 2008, 12:28
  5. Restrict size of QLineEdit
    By bruccutler in forum Newbie
    Replies: 2
    Last Post: 19th March 2007, 17:31

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
  •  
Qt is a trademark of The Qt Company.