# How can I automatically generate files like ui\_xxx.h、moc\_xxx.h form \*.ui?

**URL:** https://discourse.slicer.org/t/how-can-i-automatically-generate-files-like-ui-xxx-h-moc-xxx-h-form-ui/9878
**Category:** Development
**Created:** [January 20, 2020, 8:34am UTC](https://discourse.slicer.org/t/how-can-i-automatically-generate-files-like-ui-xxx-h-moc-xxx-h-form-ui/9878 "2020-01-20T08:34:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Shicong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shicong/32/6562_2.png) [@Shicong](https://discourse.slicer.org/u/Shicong)
#### Post date: [January 20, 2020, 8:34am UTC](https://discourse.slicer.org/t/how-can-i-automatically-generate-files-like-ui-xxx-h-moc-xxx-h-form-ui/9878/1 "2020-01-20T08:34:44Z")

</div>

I want to create a panel of my own in slicer, I copy a file such as ui and corresponding ui\_xxx.h, moc\_xxx.cpp, and change its name, smoother can run properly; I edited the .ui file in Qt, how can I automatically generate files like ui\_xxx.h, and how can the moc\_xxx.cpp file be generated automatically? Thanks.  
Like the following files, I think they are automatically generated???

 ![fang1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/d/ad9448deba20aefeb02e4f3ff9f5f3ab7e3e80b1.png)

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [January 20, 2020, 2:35pm UTC](https://discourse.slicer.org/t/how-can-i-automatically-generate-files-like-ui-xxx-h-moc-xxx-h-form-ui/9878/2 "2020-01-20T14:35:12Z")

</div>

If you add the .ui file to CMakeLists.txt (search for UI\_SRCS) then the associated files will be generated during the build process.

---

<div class="post-metadata">

### Author: ![Shicong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shicong/32/6562_2.png) [@Shicong](https://discourse.slicer.org/u/Shicong)
#### Post date: [January 21, 2020, 2:01am UTC](https://discourse.slicer.org/t/how-can-i-automatically-generate-files-like-ui-xxx-h-moc-xxx-h-form-ui/9878/3 "2020-01-21T02:01:39Z")

</div>

Thank you very much. I wish you a happy life ！！！
