Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ QT
Hi
 
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
{
    Q_OBJECT
    
public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();
    
private slots:
    void on_pushButton_clicked();
 
public slots:
    void load();
 
private:
    Ui::Dialog *ui;
};
 
#endif // DIALOG_H

 
 
void Dialog::load(){
 
    QPixmap pixmap("/home/hor/1.jpg");
    ui->label->setPixmap(pixmap);
   // label.setPixmap(pixmap);
    ui->label->show();
 
}
 
And I have an jpg image in : /home/hor/1.jpg
 
But it doesn't work!!
 
Why?
Posted 4-May-13 2:09am
hor_313631
Comments
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
good
Please Sign up or sign in to vote.

Solution 1

Quote:
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 280
1 Jochen Arndt 150
2 Kornfeld Eliyahu Peter 120
3 PIEBALDconsult 110
4 Richard MacCutchan 105
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 4 May 2013
Copyright © CodeProject, 1999-2014
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