Results 1 to 9 of 9

Thread: Image Not displaying in Qlabel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Image Not displaying in Qlabel

    Quote Originally Posted by ranjithrajrrr View Post
    Hi guys..I am trying to display a series of image in qlabel..i dono where i am going wrong. when i click the qpushbutton it displays only the last image rather displaying from beginning.
    You have a close loop in which you "display" the images.

    So what your code does is:
    - it loops through your array of image file names
    - each iteration loads the image, sets it on the label and ask for update
    - when the loop ends the event loop processed the update requests and the label displays the image that is now set

    What you probably want to do is to use a QTimer or QTimeLine to advance through the array.
    One image at a time, giving the event loop the chance to actually process the label's update request and the user to actually see the image.

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    ranjithrajrrr (27th July 2016)

  3. #2
    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: Image Not displaying in Qlabel

    This:
    Qt Code:
    1. char* picture[5] = {"D://1.png","D://2.jpg","D://3.jpg","D://4.jpg","D://5.jpg"};
    To copy to clipboard, switch view to plain text mode 
    should probably be:
    Qt Code:
    1. char* picture[5] = {"D:/1.png","D:/2.jpg","D:/3.jpg","D:/4.jpg","D:/5.jpg"};
    To copy to clipboard, switch view to plain text mode 
    to be sure the double forward-slashes are not causing files to not be found.

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

    ranjithrajrrr (27th July 2016)

Similar Threads

  1. geting QLabel text ontop of other QLabel displaying image
    By krystosan in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2013, 17:35
  2. Qlabel not displaying images other than development machine
    By arunkumaraymuo1 in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2012, 14:52
  3. Problem with displaying image using Qlabel
    By deck99 in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2011, 00:23
  4. Displaying an image
    By seltra in forum Newbie
    Replies: 2
    Last Post: 3rd October 2010, 19:30
  5. Replies: 6
    Last Post: 21st September 2009, 10:55

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
  •  
Qt is a trademark of The Qt Company.