如何在Linux中的Qt中编写图像路径? [英] How can i write the image path in Qt in Linux?

查看:555
本文介绍了如何在Linux中的Qt中编写图像路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在Linux的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();

}





我有一个jpg图片:/home/hor/1.jpg



但它不起作用!!



为什么?



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

But it doesn''t work!!

Why?

推荐答案

引用:

但它不起作用!!



信息量不大。你应该详细说明。





文档 [ ^ ]声明:


Is not pretty informative. You should elaborate.


The documentation[^] states:

如果文件不存在或者是未知的格式,pixmap变成空像素
If the file does not exist or is of an unknown format, the pixmap becomes a null pixmap



你没有检查它。


You didn''t check for it.


这篇关于如何在Linux中的Qt中编写图像路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆