Results 1 to 2 of 2

Thread: Problem with displaying image using Qlabel

  1. #1
    Join Date
    Jan 2011
    Posts
    14
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Problem with displaying image using Qlabel

    Hi........
    I have a problem while displaying an image in label. when u simply open l.png its image display is horizontal but when u open with code display is in vertical. i want the image as it is seen in simply opening and no scrollbar should come full image should be displayed on the label with no scollbars.
    Qt Code:
    1. imageLabel = new QLabel;
    2. imageLabel->setBackgroundRole(QPalette::Base);
    3. imageLabel->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
    4. imageLabel->setScaledContents(true);
    5.  
    6. scrollArea = new QScrollArea;
    7. scrollArea->setBackgroundRole(QPalette::Dark);
    8. scrollArea->setWidget(imageLabel);
    9. setCentralWidget(scrollArea);
    10.  
    11. setWindowTitle(tr("Image Viewer"));
    12. resize(800, 900);
    13.  
    14. QImage image("/home/karl/Desktop/l.tif");
    15.  
    16.  
    17. imageLabel->setPixmap(QPixmap::fromImage(image));
    18.  
    19. scaleFactor = 1.0;
    20.  
    21. scrollArea->setWidgetResizable(1);
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    • File Type: jpg l.jpg (10.0 KB, 16 views)

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with displaying image using Qlabel

    I dont quite understand! If you don't want scrollbars, then don't put your label into a scrollarea. setScaledContents should scale your pixmap to fit the labels size.

    As to the rotation: Could it be that your image viewer automatically rotates the file due to some meta information e.g. xmp or exif orientation? Because I don't think that QLabel will rotate the image by itself.

    Try an image from a different source.

    HIH

    Joh

Similar Threads

  1. Problem displaying image on a customized button
    By bhavikdhoot in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2010, 10:48
  2. problem in drawing image in QLabel!
    By mismael85 in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2010, 15:16
  3. Replies: 6
    Last Post: 21st September 2009, 10:55
  4. problem in Displaying image on push button
    By durgarao in forum Qt Tools
    Replies: 4
    Last Post: 2nd January 2009, 10:27
  5. [problem]displaying image with Pixmap
    By crazy_inf in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2008, 09:49

Tags for this Thread

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.