Click here to Skip to main content
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 2: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 Sergey Alexandrovich Kryukov 7,442
1 OriginalGriff 5,996
2 Peter Leow 4,292
3 CHill60 2,858
4 Mika Wendelius 2,850

Advertise | Privacy | Mobile
Web03 | 2.8.150224.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