Inserting QImage into a QSqlTableModel (QByteArray)

67 views
Skip to first unread message

Ralf Van Bogaert

unread,
Apr 15, 2012, 3:39:11 AM4/15/12
to lqt-bi...@googlegroups.com
Hi,

Sorry to spam the list but I'm having many questions lately.

I'm working on a program that works with image files to make slideshows with.
I use a QListView to show thumbnails. The problem is speed.

To alleviate this, I need to create thumbnails for every image. Since these are small, I'd like to store them in an qslite database, if possible.

In the Qt docs, the following method is presented;

QImage image;
QByteArray ba;
QBuffer buffer (&ba)
buffer.open(QIODevice::WriteOnly)
image.save(&buffer, 'PNG');

This would save the image as a PNG file.

But the problem is, I can't create an QByteArray since the class is not in lqt.

In some instances I can create QByteArrays, for example when converting from a QVariant.

Is it somehow possible to create a QByteArray object?

Regards

Ralf




Michal Kottman

unread,
Apr 15, 2012, 6:42:48 AM4/15/12
to lqt-bi...@googlegroups.com
On 15 April 2012 09:39, Ralf Van Bogaert <ralf.va...@gmail.com> wrote:
Sorry to spam the list but I'm having many questions lately.

I'm working on a program that works with image files to make slideshows with.
I use a QListView to show thumbnails. The problem is speed.

To alleviate this, I need to create thumbnails for every image. Since these are small, I'd like to store them in an qslite database, if possible.

In the Qt docs, the following method is presented;

QImage image;
QByteArray ba;
QBuffer buffer (&ba)
buffer.open(QIODevice::WriteOnly)
image.save(&buffer, 'PNG');

This would save the image as a PNG file.

But the problem is, I can't create an QByteArray since the class is not in lqt.

QByteArray is not in lqt because it is transparently translated to Lua string. You could map 'const char *' to Lua string instead, but you would lose some convenience. Modify generator/qtypes.lua and remove the definitions to QByteArray. 
Reply all
Reply to author
Forward
0 new messages