When I add ui , cxx, h to my module, how can add source file?

Hello all.
Is there a way to add these(.ui , .cxx , .h ) at once? Do you usually add .cxx and .h after adding ui by one click or easily way??

and I don’t know the roles of a and the rest of the project.(mymodule, mymoduleWidget ,Logic, LogicPython, etc…).
For example I can add resouce and its class( test.cpp & test.h) easy in MFC . I know way like this.
Or do I need to edit it and build it through CMAKE? I wonder if there is such a tutorial.

I tried the above-mentioned method, but I am not sure how to deal with the functions of ui that I randomly added in the module project.

Thanks for reading this.

Maybe QtDesigner or QtCreator has wizards for creating ui/cxx/h/_p.h skeletons that is similar to Visual Studio’s MFC class wizards. These can be indeed useful for the first few classes when you create a new application from scratch. If you already have an application, then you would lose a lot of time making general-purpose skeletons created by the Wizard conform to your application’s conventions. Instead it is much faster and simpler to find another class in the application that is very similar to what you need and copy and rename it and adapt it to your needs.

You follow generic Qt application development process using CMake and Visual Studio. There is nothing specific to Slicer. All these tools are use by many people, so probably you can find tutorials out there, but you can also just learn by reading the code.

In the end, you will just copy files (.cxx, .h, .ui, …), rename them and rename the class contained in them, and add the new files to the CMakeLists.txt file.

Thanks for your kindness @lassoan :slight_smile: . I’ve been learning a lot from your kind explanation for a few days.
One difficult part is the difference and function between mymodule.ui and mymodulewidget.ui. And if I look at the script module, I understand what logic does within python, but where should I define the function according to the event for the button or other tool in c++?

Usually a module has a widget that appears on the left panel. It is always built using a .ui file.

Many modules offer reusable widgets that other modules can use. If such a widget is composed of many other widgets then it is often built using a .ui file, too.