Results 1 to 4 of 4

Thread: Where can Qlabel keep its image?

  1. #1
    Join Date
    Mar 2013
    Posts
    28
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Where can Qlabel keep its image?

    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!

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Where can Qlabel keep its image?

    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
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    hind (15th July 2013)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Where can Qlabel keep its image?

    Quote Originally Posted by hind View Post
    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.

  5. The following user says thank you to ChrisW67 for this useful post:

    hind (15th July 2013)

  6. #4
    Join Date
    Mar 2013
    Posts
    28
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Where can Qlabel keep its image?

    Thanks!
    Now I've come to know that QLabel does not necesarryly keep the image it is showing.

Similar Threads

  1. Qlabel Image Panning
    By augusbas in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2011, 07:43
  2. Image in QLabel not being displayed
    By P@u1 in forum Qt Programming
    Replies: 2
    Last Post: 4th July 2011, 09:47
  3. how to move the image in QLabel
    By augusbas in forum Qt Programming
    Replies: 1
    Last Post: 13th October 2010, 08:33
  4. Replies: 6
    Last Post: 21st September 2009, 10:55
  5. QLabel as an image.
    By RSX in forum Newbie
    Replies: 2
    Last Post: 4th April 2009, 19:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.