>> I should have been more specific.  I'm using QtJambi.
>
> Thanks,
> Randy
>
> On Fri, Jul 3, 2009 at 2:40 AM, Helge Fredriksen <[email protected]> wrote:
> >  Dear Randy,
> >
> > I think you will have to consult the Qt mailing list about this issue.
> > This is the list for the QtJambi stuff, which is the Java bindings
> > towards Qt.
> >
> > Regards,
> > Helge Fredriksen
> >
> > Randy Baumgarte wrote:
> >
> > Hello,
> >
> > I'm new to QT and I'm hoping somebody can help me.  I'm trying to insert
> > binary data into a SQLite database but am running into problems.  It only
> > seems to save the first few characters of the byte array.  I've tried
> > various things but can't seem to get beyond this.  I'm sure it is
> > something I'm overlooking but would appreciate any help.  The database
> > field is a BLOB and I've been trying to use a QByteArray.  Is there some
> > special method I need to use to allow it to put the  full binary data
> > into the database?  In my case, I'm trying to save a png image.
> >
I don't know about sqlite, but in derby I use byte[] to save image with a blob 
field. I'm using this method to convert QImage to byte[].

public byte[] getImageBytes(QImage image) {

                QByteArray ba = new QByteArray();
                QBuffer buffer = new QBuffer(ba);
                buffer.open(OpenModeFlag.WriteOnly);
                if (image != null) {
                        image.save(buffer, "JPG");
                        image = null;
                }
                byte[] returnbyteArray = ba.toByteArray();
                return returnbyteArray;
        }

I thing that cause less troubles than using QByteArray.

If you are curious, I'm using eclipseLink for the persistence management 
instead of QtSql.

> > Thanks for the help!
> > Randy
> >
> > ------------------------------
> >
> > _______________________________________________
> > Qt-jambi-interest mailing
> > [email protected]http://lists.trolltech.com/mailman/lis
> >tinfo/qt-jambi-interest
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to