0

I want to show an image from mysql db on my pyqt4 application. I researched some pages about this topic. But I can not get that. I want to show the image on qlabel.

I have gui file and a callpage.py

From callpage.py I want to show like this:

self.ui.labelPicture.setPixmap(QtGui.QPixmap(img))

How to display a picture from mysql database using python?

How to insert / retrieve a file stored as a BLOB in a MySQL db using python

1 Answer 1

0

You are basically asking for 2 question. Here are two steps, the first involves you retrieving the base64 image, the second one is the actuall pyqt code.

1) First you need to get your your sql query as base64

Which is described well here: How to display a picture from mysql database using python?

2) Populate a QPixmap and pass it to your label

pm = QtGui.QPixmap()
pm.loadFromData(base64.b64decode(b64_data))
self.ui.labelPicture.setPixmap(QtGui.QPixmap(pm))
Sign up to request clarification or add additional context in comments.

1 Comment

All right. I understand why my comment/answer is deleted. I am a newbie. :) Okay. Now my actual problem is there is no image on the label widget. it is getting empty. How can I sure that my code is working?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.