【发布时间】:2012-12-02 19:11:20
【问题描述】:
我在主窗口中创建了一个标签,其大小设置为 200x300px。现在单击按钮,我需要查看其中的图像。这里是按钮的槽函数。
void MainWindow::function1(){
QImage img;
img.loadFromData("test.jpg");
img = img.scaled(200, 300, Qt::KeepAspectRatio, Qt::SmoothTransformation);
label->setPixmap(QPixmap::fromImage(img));
}
问题是编译没有错误,但不显示图像。按下按钮时会在 IDE 中显示 QImage::scaled: Image is a null image
我是qt的新手。我会非常感谢任何建议。
谢谢
【问题讨论】: