[Interest] Qt Sql BLOB data converting

Yauheni Pervenenka yauheni.pervenenka at viber.com
Mon Nov 28 09:32:05 CET 2022


Hi, Tony, thanks for your reply,
OS: win 11
DB: SQLite

Unfortunately, QVariant::toByteArray returns size 52(hex 104),
QVariant::toString returns size 30

There is data returned by QVariant::toByteArray::toHex
Qt data in hex(size 104):
763130492d46c2ab4cc29c7bc2b0efbfbd78c29b29c3ab1e4723dea6efbfbdefbfbdefbfbdefbfbd66c2a275efbfbdefbfbdc4a6

Original value in hex
size(68): 763130492d46ab4c9c7bb0e9789b29c3ab1e4723dea6c8e5d2f9b266a275e1fbe4a6

there are some data that is parsed correct but time to time it is broken



On Mon, Nov 28, 2022 at 11:17 AM Tony Rietwyk <tony at rightsoft.com.au> wrote:

> Hi Yauheni,
>
> You don't say which type of database you are using?  There may be issues
> with the database client library altering the blob to UTF8.  Though I
> would expect the python code using the same client to have the same
> problem.
>
> Assuming that QVariant has the byte array unaltered, then
> QVariant.toByteArray().length() should give 34.  Using qstrlen, suggests
> that you are using QVariant.toString instead.  To print the hex you
> should just use QVariant.toByteArray().toHex().
>
> Hope that helps,
>
> Tony
>
>
> On 28/11/2022 6:46 pm, Yauheni Pervenenka via Interest wrote:
> > Hello, community
> > I have faced with issue that qvariant using qstrlen for getting data
> > size, but sometimes it returns wrong size especially for BLOB data(if
> > there are some special symbols), are there any way to get data correct?
> >
> > Note:
> > Database value 34, python returns correct data size, but
> > qvariant::toByteArray returns 52
> >
> > Python data and Database data in hex(size
> > 68): 763130492d46ab4c9c7bb0e9789b29c3ab1e4723dea6c8e5d2f9b266a275e1fbe4a6
> >
> > Qt data in hex(size 104):
> >
> 763130492d46c2ab4cc29c7bc2b0efbfbd78c29b29c3ab1e4723dea6efbfbdefbfbdefbfbdefbfbd66c2a275efbfbdefbfbdc4a6
> >
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > https://lists.qt-project.org/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20221128/81882cbf/attachment.htm>


More information about the Interest mailing list