Hello everyone,
I'm new to development with FreeCAD and Qt. I want to add some new functionality to FreeCAD. I have an old programm (written in c++) and want to use it with FreeCAD. Therefore I created a new workspace. Now I try to create some new dialogs for data input that I need.
I develop with Visual Studio and installed Qt and Qt plugin vor VS. If I create a new dialog with Qt Designer I don' get it, how to use this *.ui file within FreeCAD. I think i need a *.h file (how can I automatically create this with Qt?) I found only documentation for python, hence the old code is in c++ and I'm better with c++ I want to do this in c++. Can you tell me how to do this, or do you have a good tutorial for me?
Using *.ui files with c++
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Using *.ui files with c++
The magic happens in myModule/Gui/CMakeLists.txt. These two lines:
generate .cpp and .h files from your .ui.
you then include them in your dialog code.
The generated files hide all the messy bits of building the ui in your code.
Code: Select all
fc_wrap_cpp(TechDrawGui_MOC_SRCS ${TechDrawGui_MOC_HDRS})
qt4_wrap_ui(TechDrawGui_UIC_HDRS ${TechDrawGui_UIC_SRCS})
generate .cpp and .h files from your .ui.
you then include them in your dialog code.
Code: Select all
#include <Mod/TechDraw/Gui/ui_TaskLinkDim.h>
...
#include <Mod/TechDraw/Gui/moc_TaskLinkDim.cpp>
Re: Using *.ui files with c++
Thanks for the answer!
i have added my *.ui files in the CMakeLists.txt. But where do I find the generated *.h and *.cpp files? They are neither in the folder /src/Mod/MyModule/Gui, nor in Mod/MyModule.
i have added my *.ui files in the CMakeLists.txt. But where do I find the generated *.h and *.cpp files? They are neither in the folder /src/Mod/MyModule/Gui, nor in Mod/MyModule.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Using *.ui files with c++
I had trouble finding them too! They're in the build directory: BuildDir/src/Mod/MyModule/Gui...Oli wrote:Thanks for the answer!
i have added my *.ui files in the CMakeLists.txt. But where do I find the generated *.h and *.cpp files? They are neither in the folder /src/Mod/MyModule/Gui, nor in Mod/MyModule.
Your includes will have to include path info:
Code: Select all
#include <Mod/TechDraw/Gui/ui_TaskLinkDim.h>
...
#include <Mod/TechDraw/Gui/moc_TaskLinkDim.cpp>