Click here to Skip to main content
11,790,613 members (62,935 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ QT

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 at 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
0 OriginalGriff 1,114
1 Maciej Los 825
2 KrunalRohit 686
3 CPallini 611
4 ppolymorphe 610

Advertise | Privacy | Mobile
Web03 | 2.8.1509028.1 | Last Updated 4 May 2013
Copyright © CodeProject, 1999-2015
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