Check the .ui file. The label imageLabel you want to set does not exist in the UI. Redo and remove the QLabel *imageLablel; from the header file. You can also remove the QLabel header (it will be included from ui_window.h).
Check the .ui file. The label imageLabel you want to set does not exist in the UI. Redo and remove the QLabel *imageLablel; from the header file. You can also remove the QLabel header (it will be included from ui_window.h).
Do you mean adding QLabel *imageLabel to ui_window.h file? I think .ui file is edited in Qt Creator Designer. So I added QLabel *imageLabel to ui_window.h file and deleted it in window.h file. The program can pass the compile now, but it doesn't show a window as I expected. Do you know what the problem is?
No. Do not edit .ui files yourself (unless you are fixing Designer's errors). Remove the changes done by yourself, open the .ui. file in the Designer, and check the label. It has a different name, it is not a QLabel, or it is not in the .ui file at all. Fix the label, save, and try again.
Thank you, you answer helps a lot! I added a label in .ui file, using Designer. Also, I found in ui_window.h, there's a declaration: QLabel *label; so I gave up imageLabel and used label instead. Now I can open the window and show the picture.
Bookmarks