Solved QLabel added in Designer, no corresponding object in ui*.h
-
Hi, I'm enhancing a program I wrote in Qt last year.
It is a touch screen-based app with a very simple UI hierarchy like this:
MainApp (QMainWindow) centralWidget (QWidget) label1 (QLabel) label2 (QLabel) label3 (QLabel)
In ui_mainapp.h, the following was generated:
class Ui_MainApp { public: QWidget *centralWidget; QLabel *label1; QLabel *label2; QLabel *label3; // etc. }
Now, I'd like to add a fourth QLabel. So I drag and drop the label in Qt Designer. It appears in the edit window, I can set its properties and it is shown in the object list with the other three. However, no object is created in the ui_mainapp.h file. Consequently, I have nothing to reference in my code
Is there something I'm missing?
Thanks in advance.
Dave
-
@Dave-Colter said in QLabel added in Designer, no corresponding object in ui*.h:
I tried commenting one of the QLabel declarations in ui_mainapp.h and rebuilt
You dont have to edit the
ui_xxxx.h
at all. It's generated by qmake from your Qt Designer file (*.ui).
So yes, you can delete it.Try:
Close your project and Qt Creator / Designer and re-open it again. Sometimes there are cached or autosaved files, so qmake doesnt see any changes. -
Clean up your project, then run qmake / build and compile again.
-
Thanks for the reply. Tried that to no avail. I get the message
make: Nothing to be done for 'qmake_all'.
Now you say "clean up your project". I did a Clean All from the build menu; is there anything else I can do? I tried commenting one of the QLabel declarations in ui_mainapp.h and rebuilt. I got the compile errors you might expect, so the file is not being regenerated, even on a Clean All/Rebuild All. Can the file be safely deleted to force regeneration?
-
@Dave-Colter said in QLabel added in Designer, no corresponding object in ui*.h:
I tried commenting one of the QLabel declarations in ui_mainapp.h and rebuilt
You dont have to edit the
ui_xxxx.h
at all. It's generated by qmake from your Qt Designer file (*.ui).
So yes, you can delete it.Try:
Close your project and Qt Creator / Designer and re-open it again. Sometimes there are cached or autosaved files, so qmake doesnt see any changes. -
@Dave-Colter
Hi,
Try to remove build directory from file manager, sometimes I saw that clear all isn't useful to remove this issue, -
OK -- I deleted all the ui_.h files, all the moc_.cpp files and the debug folder. Then I did a Clean All/qmake/Rebuild All.
It works!! Thank you!!
The only odd thing is that now the generated files are saved only in my debug folder. I used to have copies in my main project folder. However, when I initially created this app last year, I was learning Qt from scratch. I guess it was something I did back then that left the copies in my main folder.
Thanks again!
Dave
-
Hi, just seeing your reply now as I've been banging away on my project. Deleting the build (debug) folder was indeed part of the solution. Thanks for your reply.