Results 1 to 2 of 2

Thread: [problem]displaying image with Pixmap

  1. #1
    Join Date
    Jul 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default [problem]displaying image with Pixmap

    Hiya world ....
    I have just started to do my own Qt projects....and I crossed a lot of problems realy !!
    Okey , without be long..i give you my source code..
    Qt Code:
    1. #include "visionneur.h"
    2.  
    3. Visionneur::Visionneur(): QWidget()
    4. {
    5.  
    6. m_ouvrir=new QPushButton("Ouvir une image",this);
    7. QObject::connect(m_ouvrir,SIGNAL(clicked()),this,SLOT(ouvrir()));
    8. m_contenu=new QLabel(this);
    9. m_contenu->setFrameShape(QFrame::Panel);
    10. m_contenu->setPixmap(QPixmap("image.png"));
    11.  
    12. }
    13. void Visionneur::ouvrir()
    14. {
    15. QString image = QFileDialog::getOpenFileName(this, "Ouvrir un fichier", QString(), "Images (*.png *.gif *.jpg *.jpeg)");
    16.  
    17. }
    18. Visionneur::~Visionneur()
    19. {
    20. }
    To copy to clipboard, switch view to plain text mode 
    Problem: the image doesnt apear on my window
    I'd like some help to resolve that probleme , I'm using Dev-c++

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [problem]displaying image with Pixmap

    possible issues:
    * make sure image.png is in the directory you call your program from
    * set a layout on your widget
    * check that your Qt build supports .png
    try
    Qt Code:
    1. QLabel *l = new QLabel;
    2. l->setPixmap(QPixmap("image.png"));
    3. l->show();
    To copy to clipboard, switch view to plain text mode 
    Does this show the image?

    HTH

Similar Threads

  1. Qt 3.3.8 pixmap to/from image error
    By ksierens in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2008, 07:46
  2. finding maximum scaling of a pixmap
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 31st March 2008, 15:32
  3. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 03:10
  4. Create pixmap image from string
    By Morea in forum Qt Programming
    Replies: 5
    Last Post: 17th November 2006, 17:38
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 17:36

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.