[英]How to update a QLabel to display a QImage
I may be misunderstanding how to do this, hopefully somebody can clarify. 我可能会误解该怎么做,希望有人能澄清一下。
I have placed a QLabel
on my main window from inside Qt Designer. 我已经从Qt Designer内部将
QLabel
放置在主窗口中。 Currently, it just displays the letters " TextLabel
" when I run the program. 当前,当我运行程序时,它仅显示字母“
TextLabel
”。
I have a line edit where I type in the path to an image, which then loads the image as a QImage
into memory (I have this working). 我进行了行编辑,在其中键入图像的路径,然后将图像作为
QImage
加载到内存中(我正在工作)。
Finally, I want to display this QImage
. 最后,我要显示此
QImage
。 I was told this can be done by QLabels
. 有人告诉我
QLabels
可以做到这QLabels
。 I have done the following, but nothing is happening: 我已完成以下操作,但没有任何反应:
ui.input_label->setPixmap(QPixmap::fromImage(my_qimage));
Why is nothing happening? 为什么什么也没发生? How can I display this image?
如何显示此图像?
If you are sure the image file is ok but then the problem is probably with loading the file into the QImage
. 如果您确定图像文件可以,但是问题可能出在将文件加载到
QImage
。 If you are calling QImage::load()
, you are probably getting a return value of false
. 如果调用
QImage::load()
,则可能会得到false
的返回值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.