[PyQt] retrieving images(blob) from sqlite db
michael h
michaelkenth at gmail.com
Sat Aug 24 17:13:58 BST 2019
On Sat, Aug 24, 2019 at 4:39 AM Ali M <adeadmarshal at gmail.com> wrote:
> I've created a sqlite db with a blob field and put images in it. how can i
> retrieve the images and show them in a qtextbrowser? i want to get the
> images with a for loop something like the below code but i don't know how.
>
> def readImage(self):
> cur = self.db.cursor()
> rows = cur.execute("select cover from covers")
> pm = QPixmap()
> for row in rows:
> pic = self.ui.label.setPixmap(QPixmap("row.jpg"))
> self.ui.textBrowser.insertFromMimeData(pic)
>
You can use loadFromData(thebytes) to load a QPixmap from bytes, however
you may use a QImage (which also has loadFromData) and
https://doc.qt.io/qt-5/qtextcursor.html#insertImage-3 because it looks
easier to me
(insertFromMimeData won't work on a QPixmap anyhow AFAICT)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190824/b7f199e8/attachment.html>
More information about the PyQt
mailing list