PDA

View Full Version : Where can Qlabel keep its image?



hind
12th July 2013, 09:47
As far as I know, QLabel keeps its image in a pixmap or a picture.
Now I am working on a third party library which takes a HWND and draws pictures into that window. I give it a QLabel::winId() and it works just fine. But when I want to take the image the QLabel is showing and do some process, I fail because either the pixmap or the picture points returns NULL.
Apparently there is still somewhere else QLabel keeps image data or has access to.
Thanks in advance!

Santosh Reddy
12th July 2013, 10:14
I don't think you can access it directly uing Qt API. You will either need windows API, or third party library API to read the image

ChrisW67
13th July 2013, 11:12
I give it a QLabel::winId() and it works just fine. But when I want to take the image the QLabel is showing and do some process, I fail because either the pixmap or the picture points returns NULL.
You are telling the other library to draw stuff in the on-screen space occupied by the QLabel. The QLabel has nothing to do with drawing whatever that library puts on the screen in that place and cannot, therefore, return that image data in a QImage or QPixmap. If you want the image data that the other library is drawing then you will need to get that from the other library or, as Santosh said, use a Windows API call to scrape it off the screen. You could try QScreen::grabWindow() (Qt5) or QPixmap::grabWindow() but I would not expect reliable results.

hind
15th July 2013, 03:11
Thanks!
Now I've come to know that QLabel does not necesarryly keep the image it is showing.