Click here to Skip to main content
13,055,083 members (64,014 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I have wrote this code in Qt in Linux :

#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
class Dialog : public QDialog
    explicit Dialog(QWidget *parent = 0);
private slots:
    void on_pushButton_clicked();
public slots:
    void load();
    Ui::Dialog *ui;
#endif // DIALOG_H

void Dialog::load(){
    QPixmap pixmap("/home/hor/1.jpg");
   // label.setPixmap(pixmap);

And I have an jpg image in : /home/hor/1.jpg

But it doesn't work!!

Posted 4-May-13 1:09am
jsolutions_uk 4-May-13 7:49am
With jpg images, you need to make sure the jpeg imageformat plugin is loaded. I know on Windows it is found in (QTDIR)/plugins/imageformats/ I can't be sure where it is found on Linux off the top of my head. Usually I would place this file in the output folder for your project, under a plugins/imageformats/ folder. Hope that helps.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

But it doesn't work!!

Is not pretty informative. You should elaborate.

The documentation[^] states:
If the file does not exist or is of an unknown format, the pixmap becomes a null pixmap

You didn't check for it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 4 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100