How to remove manually created form and replace with QTDesigner creatted one.
-
This post is deleted!
-
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
"how does QTDEsigner interact with QTCreator "
It does not.
The designer creates ui files, the uic executable translates them in ui_.h files. Already explained to you e.g. here: https://forum.qt.io/topic/125497/editing-ui-c-code -
@Christian-Ehrlicher How does that ANSWERS the question as posted NOW?
When the question gets answered ,
please elaborate how QTCreator and QTDesigner DO NOT RELATE.( Using QTCreator I can build a dialog project whose form can be edited in QTDesigner...)
-
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
Using QTCreator I can build a dialog project whose form can be edited in QTDesigner
Correct, QtCreator has also a built-in designer mode. But that doesn't matter for your question. It doesn't matter if you create the ui-file within the QtCreator built-in designer or the external QtDesigner. Both create exact the same ui file and the workflow how to use it is also exactly the same as explained to you in the other thread already.
-
@AnneRanch
Let's see if this helps:-
Qt Designer only uses the
form.ui
file. It does not know or care about any other file. It does not care about Qt Creator. The.ui
file is a textual (XML) description of everything you have designed in Designer. Designer can read that and recreate what you had visually when it was saved; when you make changes in Designer and save everything goes into the.ui
file. -
When you build your project from Creator, (if the
.ui
has changed) it runs executableuic
on the.ui
file. That also only looks at the.ui
file. From the XML in ituic
generates a file namedui_form.h
, situated in the build output directory (where the.o
files are) not your source files directory. That.h
file is C++ code for everything in the.ui
file. The actual.ui
file is not needed after this point, it is not read/required at runtime for your project/executable. -
In your
form.cpp
file --- original generated together withform.h
from Creator when you told it to add the Form into your project, but from then onward never updated by Creator, only by you --- there is a#include "ui_form.h"
line to read in the.h
code file generated from the.ui
byuic
and a call toui->setup(this)
. That uses the generated code to implement what you designed via the appropriate C++ Qt library calls at runtime. The compilation does not know or care where theui_form.h
came from ---.ui
file run throughuic
or not --- so long as that file contains all the C++ code required.
So, you can generate the
ui_form.h
from the original.ui
Designer file viauic
; but note that you cannot regenerate the original.ui
file from the generatedui_form.h
, it's a one-way process only. Which is why you don't want to lose the.ui
file, if you want to keep going back and making changes. You can lose theui_form.h
file any time, because you can always re-runuic
on the.ui
file. Finally note that you should never change the.ui_form.h
file itself, because it will be overwritten and any alterations you made lost, the next time the build runsuic
. You may look at the code inui_form.h
to understand howuic
is turning your.ui
file into C++ code if you wish, but do not try to change it.In your case, if you have a
.ui
file you should be able to get back into viewing/editing it in Designer. Provided its content is "legal" (per the XML format it understands) and you have not manually put stuff into it that it does not understand/deal with. If you do not have a.ui
file you will not be able to generate one and will not be able to get into Designer on the form. -
-
@JonB Thanks very much , your post is indeed very helpful. Let me digest it and hopefully I can then ask more intelligent questions.
At his point is am still not sure how using QTDesigner to build actual C code
differs from starting with QTCreator and ending up with same C code and be able to edit the "form" in QTDesigner.
Thanks -
Ok , allow me to start a discussion from coder , me , view.
I can access "Form" file xxx .ui file , in creator.
That gets me to QTDesigner and I can edit the form. At that point I have no knowledge how my editing gets implemented - sort of "under the hood" .
I exit the QTDesigner and go back to QTCreator only to find out that simple change of text of button text did not take.So - it is "one way street " and now is time to trace "under the hood" to find out why...keeping in focus it works OK when QTCreator build the xxxx.ui file.
Starting where ?
-
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
At his point is am still not sure how using QTDesigner to build actual C code
Truly, Qt Designer does not build any code at all. Qt Designer only reads & writes a
.ui
(XML) file. That's it: no more and no less. No code at all. When you design from scratch and save, Designer saves your design into a.ui
file. When you later read that.ui
file into Designer, it reconstructs the visual design from that file.Qt Creator, OTOH, does lots of things. These include:
-
Embed Designer in one of its windows, so that you can design forms. That, as stated above, writes & reads a
.ui
file. -
When you build, Creator calls on
make
. If the.ui
file read/written by Designer has been changed, runuic
on the.ui
file to generateui....h
file from it. That is C++ code. But it's not produced by Designer (or even by Creator); it's produced byuic
executable (supplied with Qt). -
After generating
ui....h
file from.ui
(or using the last left around if.ui
has not been updated), thenmake
calls ongcc
to compile all source files necessary (there will be#include "ui_form.h"
inform.cpp
, so this step will#include
the C++ code generated fromuic
on.ui
files), and finally to link all object/library files into an executable.
Of course, Creator does much more. For example, it includes a window for the text editor with C++ knowledge, a window for running
gdb
debugger if you want it, and other things. Creator is largely a big, complex "shell", pulling all these bits together into a single IDE, so that you can do more or less anything you want from within Creator without having to manually run up separate programs/tools manually/explicitly. -
-
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
That gets me to QTDesigner and I can edit the form. At that point I have no knowledge how my editing gets implemented - sort of "under the hood" .
Designer reads the .
ui
file, and saves back to it if you make changes and save.I exit the QTDesigner and go back to QTCreator
You should not be "exiting" the Designer or "go back to" Creator. You should be in Creator the whole time, never leaving it. Designer is available as a window inside Creator, which gets opened for you when you double click on a form. It's a window like many other windows in Creator, e.g. the C++ text editor is also a window there. You should be swapping between the Designer window and the Editor window all from within Creator.
only to find out that simple change of text of button text did not take.
Then something is wrong. When you say "change of text of button text did not take." you might mean you see that in one of two places. Can you be very specific:
-
You are looking at the button in Designer. You have not compiled or run your application after making a change. Is this where you do not see your edit?
-
You have compiled and run your application. In your running application you do not see your edit. Is this what you mean?
Obviously if #1 is true then #2 is (likely to be) true. But #2 might be true without #1 being true. So I'm sure you fall foul in #2, but is #1 bad fro you too? You made a change in Designer, saved; at a later date you are looking at in Designer and you do not visually see the change? Or do you always see your change visually in Designer but it does not "take" into the running application code?
Returning to earlier:
I exit the QTDesigner and go back to QTCreator
We really need to know exactly what you mean by this. If you are really running just Qt Designer as a separate thing you do, outside of Creator, that's wrong, and might cause problems if they do not have the exact same path to the
.ui
file. -
-
@JonB Next step ( before I read your last post )
I am working with "device"
Who "reads" the 'device.ui' ?
More precisely -0 how do I know it was actually read ?I find this description little misleading -
The term "form " is introduced , but actually
ui-device.h FILE , not form , is generated by reading the "device.ui"Form generated from reading UI file 'device.ui'
So if (?) "device.ui" is read - why my change in the actual l form did not take?
-
@AnneRanch
When you create a form in Designer (that's the word it uses for a "visual widget you design") you might call itform
ordevice
orbanana
. Let's say it'sbanana
. Then:- The Designer file for the form (visual widgets) will be
banana.ui
. - When
uic banana.ui
gets run it will produce a file namedui_banana.h
. - You will also have files
banana.cpp
andbanana.h
, which you can edit for your own code. banana.cpp
will have a#include "ui_banana.h"
line and a#include "banana.h"
line.
So if (?) "device.ui" is read - why my change in the actual l form did not take?
Maybe when you answer questions in my previous post about what you might mean by "I exit the QTDesigner and go back to QTCreator only to find out ..." we may know.
- The Designer file for the form (visual widgets) will be
-
@JonB said in How to remove manually created form and replace with QTDesigner creatted one.:
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
That gets me to QTDesigner and I can edit the form. At that point I have no knowledge how my editing gets implemented - sort of "under the hood" .
Designer reads the .
ui
file, and saves back to it if you make changes and save.I exit the QTDesigner and go back to QTCreator
You should not be "exiting" the Designer or "go back to" Creator. You should be in Creator the whole time, never leaving it. Designer is available as a window inside Creator, which gets opened for you when you double click on a form. It's a window like many other windows in Creator, e.g. the C++ text editor is also a window there. You should be swapping between the Designer window and the Editor window all from within Creator.
only to find out that simple change of text of button text did not take.
Then something is wrong. When you say "change of text of button text did not take." you might mean you see that in one of two places. Can you be very specific:
-
You are looking at the button in Designer. You have not compiled or run your application after making a change. Is this where you do not see your edit?
-
You have compiled and run your application. In your running application you do not see your edit. Is this what you mean?
Obviously if #1 is true then #2 is (likely to be) true. But #2 might be true without #1 being true. So I'm sure you fall foul in #2, but is #1 bad fro you too? You made a change in Designer, saved; at a later date you are looking at in Designer and you do not visually see the change? Or do you always see your change visually in Designer but it does not "take" into the running application code?
Returning to earlier:
I exit the QTDesigner and go back to QTCreator
We really need to know exactly what you mean by this. If you are really running just Qt Designer as a separate thing you do, outside of Creator, that's wrong, and might cause problems if they do not have the exact same path to the
.ui
file.Please give me some credit - just because I do not spell / say I complied it does not mean I did not. Most of the time QT works as expected and compiles automatically after change is made.
-
-
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
Please give me some credit - just because I do not spell / say I complied it does not mean I did not.
I have no idea what you mean. All I have done is try to explain things. I have not "failed to give you credit" for anything at any stage. If you're not happy with the explanation we can leave it, but I'm not going to be told I have not given you credit or been anything other than helpful and polite.
You haven't answered the question I gave you about #1 versus #2, so I am non the wiser as to where your phrasing of "why my change in the actual l form did not take?" refers to. Nor what your "I exit the QTDesigner and go back to QTCreator" means --- I can't tell whether you are in Creator the whole time and use Designer in one of its windows, or whether you go outside Creator and run up a separate Designer instance.
-
Here is the screenshot of QTDesigner
Here is the app run
Please note the button text in lower right corner .
How do I find WHICH whatever file (device ??? ) is run ?
-
@JonB said in How to remove manually created form and replace with QTDesigner creatted one.:
@AnneRanch
When you create a form in Designer (that's the word it uses for a "visual widget you design") you might call itform
ordevice
orbanana
. Let's say it'sbanana
. Then:- The Designer file for the form (visual widgets) will be
banana.ui
. - When
uic banana.ui
gets run it will produce a file namedui_banana.h
.
- How do I verify
a. If `uic " runs at all ?
is there verbatim output available ?
(can i read the date of creation of NEW ui_deviice.h - where ?)
b. It appears that there are at lest TWO "device.ui" - therefore which one is being run - by "uic" ?
- You will also have files
banana.cpp
andbanana.h
, which you can edit for your own code.
That would defeat the GUI of QTDesigner....
banana.cpp
will have a#include "ui_banana.h"
line and a#include "banana.h"
line.
That looks as an answer to above "date of creation " question.
So if (?) "device.ui" is read - why my change in the actual l form did not take?
Maybe when you answer questions in my previous post about what you might mean by "I exit the QTDesigner and go back to QTCreator only to find out ..." we may know.
PLEASE ..... get real....
- The Designer file for the form (visual widgets) will be
-
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
(can i read the date of creation of NEW ui_deviice.h - where ?)
man ls
is your friend. Or a simple file manager which is able to show the creation date (so I would say all of them).b. It appears that there are at lest TWO "device.ui" - therefore which one is being run - by "uic" ?
There is only one in a build directory, otherwise you should clear you build dir and start over. Also the generated file must not be in your source dir - maybe you copied it by accident in there.
-
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
That would defeat the GUI of QTDesigner....
Told you what there is. You're wrong if you think/believe otherwise.
b. It appears that there are at lest TWO "device.ui" - therefore which one is being run - by "uic" ?
Hence your issue, as suspected.
PLEASE ..... get real....
Pardon? You're not wishing to be insulting again are you?
-
@Christian-Ehrlicher said in How to remove manually created form and replace with QTDesigner creatted one.:
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
(can i read the date of creation of NEW ui_deviice.h - where ?)
man ls
is your friend. Or a simple file manager which is able to show the creation date (so I would say all of them).QTCreator does same
b. It appears that there are at lest TWO "device.ui" - therefore which one is being run - by "uic" ?
There is only one in a build directory, otherwise you should clear you build dir and start over. Also the generated file must not be in your source dir - maybe you copied it by accident in there.
'
it is source directory and I did not put it there .It is same as when I use QTCreator to build dialog project and it works / updates just fine.
All good points...'
Now let's answer this - used as a troubleshooting aid
I added "go to slot " by pressing the button on the form in question
it works as expectedmy conclusion
the form was saved / updated/ complied /uic and processed correctlyso WHY same is not happening when text of the button is changed ?
what is the difference ?
-
@JonB said in How to remove manually created form and replace with QTDesigner creatted one.:
@AnneRanch
When you create a form in Designer (that's the word it uses for a "visual widget you design") you might call itform
ordevice
orbanana
. Let's say it'sbanana
. Then:- The Designer file for the form (visual widgets) will be
banana.ui
. - When
uic banana.ui
gets run it will produce a file namedui_banana.h
.
I have deleted existing references ( include ) to my ui_device .h .
Run "clear" AND "rebuild" .It failed with multiple errors .....
If file "ui_device.h " is "produced" - where is it ?
It seems logical the compiler has to be made aware of it - using "include ".
Is there any other way to make sure it is being created ?- You will also have files
banana.cpp
andbanana.h
, which you can edit for your own code. banana.cpp
will have a#include "ui_banana.h"
line and a#include "banana.h"
line.
So if (?) "device.ui" is read - why my change in the actual l form did not take?
Maybe when you answer questions in my previous post about what you might mean by "I exit the QTDesigner and go back to QTCreator only to find out ..." we may know.
- The Designer file for the form (visual widgets) will be
-
@AnneRanch said in How to remove manually created form and replace with QTDesigner creatted one.:
If file "ui_device.h " is "produced" - where is it ?
Your
ui_device.h
should be being produced in the "build output directory", for which ever configuration *debug, release, ...) you are building for. Cannot say for sure where yours is, depends on your configuration settings. I often put mine in a difference place. If you are using the default I think you go to the parent of the directory containing your source files and look for a directory named something likebuild-projectname-debug...
. Your compiler's.o
files are there, as is your executable.If you have a
ui_....h
file in the same directory as your source files (where the....ui
file is), that is bad, try deleting it.Do not delete your
.ui
files though till you are sure what is going on! Keep a backup copy.I have deleted existing references ( include ) to my ui_device .h .
If you remove the
#include "ui_device.h"
line from yourdevice.cpp
file it will not compile.ui_device.h
holds the C++ generated from the.ui
, and yourdevice.cpp
will likely be making lots of references to its content.