Elements added by QtDesigner does not show up in QtCreator
-
I've noticed that when I add a new component to my .ui file with QtDesigner, the new component does not show up when I start to write
ui->
in my MainWindow class.
For regular C++ files, member variables and functions shows up in a list when I write
my_object->
Is there something I have to do to make ui-related things appear? It seems that some stuff I added earlier (I've closed Qtcreator since they were added) are found and listed when I write
ui->
-
I've noticed that when I add a new component to my .ui file with QtDesigner, the new component does not show up when I start to write
ui->
in my MainWindow class.
For regular C++ files, member variables and functions shows up in a list when I write
my_object->
Is there something I have to do to make ui-related things appear? It seems that some stuff I added earlier (I've closed Qtcreator since they were added) are found and listed when I write
ui->
-
@JonB said in Elements added by QtDesigner does not show up in QtCreator:
@Noobish Have you (re-)run
uic
to (re-)generate the (now changed) C++.h
file?No I have not, well not directly any way. Even if I build the client, which I assume would run uic at some step,, I still dont get the new components to show up in Creator when writing code.
The mainwindow.cpp file contains the line:
#include "./ui_mainwindow.h"
I found the the file in
build/Desktop-Debug/projectname_autogen/include/ui_mainwindow.h
So I guess it is placed in a directory that is not parsed by qt creator?
Should I try tell QtCreator to look for source code in that directory also? Or what should I do? I dont want to do some manual labour (well, I could run an infinite loop making calls to uic or watch for the gui file to change, but I'd rather QtCreator would handle that for me automatically. -
@JonB said in Elements added by QtDesigner does not show up in QtCreator:
@Noobish Have you (re-)run
uic
to (re-)generate the (now changed) C++.h
file?No I have not, well not directly any way. Even if I build the client, which I assume would run uic at some step,, I still dont get the new components to show up in Creator when writing code.
The mainwindow.cpp file contains the line:
#include "./ui_mainwindow.h"
I found the the file in
build/Desktop-Debug/projectname_autogen/include/ui_mainwindow.h
So I guess it is placed in a directory that is not parsed by qt creator?
Should I try tell QtCreator to look for source code in that directory also? Or what should I do? I dont want to do some manual labour (well, I could run an infinite loop making calls to uic or watch for the gui file to change, but I'd rather QtCreator would handle that for me automatically.@Noobish
For code completion the.ui
must be processed byuic
to produce theui_....h
file as C++ code. This should happen as part of build, every time you update the.ui
or force clean rebuild. There are many little things you can investigate:-
For qmake the
.h
file is generated into the build output directory (where object and executable files are). I do not know for cmake, where you say you found it may be reasonable. -
Make sure there are no other instances of that file elsewhere which could be picked up.
-
Update the
.ui
, do a build, verify the timestamp on the.h
has been updated. -
Read the
.h
into Creator and have a look through it. It's just C++ code. Verify you can see the lines generated for the components you add. -
Forget about code completion for a moment. Type in what (you believe) is right to access some new
ui->
element in your code. Do an actual compile/build. If that errors on your new component you are doing something wrong; if that succeeds but the code completion does not you have some problem in the latter area. -
Do a complete delete and rebuild.
-
Create a brand new, standalone project elsewhere and see how you get on with creating new components.
-