Results 1 to 3 of 3

Thread: QImange help loading image

  1. #1
    Join Date
    Aug 2011
    Posts
    1
    Qt products
    Qt4

    Default QImange help loading image

    I'm trying to load a image in qt4 windows and I can't get it to work

    thanks for the help
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. im = new QPixmap;
    7. im->load ("im04.jpg");
    8. }
    9.  
    10. MainWindow::~MainWindow()
    11. {
    12. delete ui;
    13. }
    14.  
    15. void MainWindow::paintEvent (QPaintEvent *){
    16. QPainter qpainter (this);
    17. qpainter.drawPixmap (0, 0, *im);
    18. }
    19. /////.h
    20. class MainWindow : public QMainWindow
    21. {
    22. Q_OBJECT
    23.  
    24. public:
    25. explicit MainWindow(QWidget *parent = 0);
    26. ~MainWindow();
    27. protected:
    28. QPixmap *im;
    29. void paintEvent (QPaintEvent *);
    30. private:
    31. Ui::MainWindow *ui;
    32.  
    33. };
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 8th August 2011 at 08:38. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: QImange help loading image

    Does it work with a png image? If so, you forgot to "include" the jpeg plugin or your path to the image is wrong.

  3. #3
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    9
    Thanked 5 Times in 5 Posts

    Default Re: QImange help loading image

    Whenever I load images into GUI, I always register them in the gui widget by using QtDesigner and using QImage to show them in paintEvent and works fine for me at all time.

    Regards,
    Dong Back Kim

Similar Threads

  1. Loading Image
    By navi1084 in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2011, 06:07
  2. Loading an image in a thread
    By DarkyDuck in forum Qt Programming
    Replies: 3
    Last Post: 11th January 2011, 19:28
  3. Loading an image into memory
    By Luc4 in forum Qt Programming
    Replies: 6
    Last Post: 12th April 2010, 09:44
  4. problems loading an image .jpg
    By maider in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2009, 12:57
  5. Image Loading
    By kavinsiva in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2009, 09:00

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.