Re: retrieving images(blob) from sqlite db
michael h <[email protected]>
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <CAD0nt=FT8EtJk3EqjzSyyqAEoaCxPrX_ZJM6gy2R3b1Rt3QKwg@mail.gmail.com> |
On Sat, Aug 24, 2019 at 4:39 AM Ali M <[email protected]> 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) _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt