# How to use my custom qt-widget in python?

**URL:** https://discourse.slicer.org/t/how-to-use-my-custom-qt-widget-in-python/31327
**Category:** Development
**Created:** [August 24, 2023, 6:57am UTC](https://discourse.slicer.org/t/how-to-use-my-custom-qt-widget-in-python/31327 "2023-08-24T06:57:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![shanfl](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@shanfl](https://discourse.slicer.org/u/shanfl)
#### Post date: [August 24, 2023, 6:57am UTC](https://discourse.slicer.org/t/how-to-use-my-custom-qt-widget-in-python/31327/1 "2023-08-24T06:57:08Z")

</div>

I create a Qt widget named ‘MyWidget’ in Modules-Markups-Widgets project.but in python script ,  
it occour error,say: slicer.MyWidget is not found ,but slicer.qSlicerSimpleMarkupsWidget can use.  
my ‘MyWidget’ and qSlicerSimpleMarkupsWidget are in same project . I dont know why?

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [August 24, 2023, 1:30pm UTC](https://discourse.slicer.org/t/how-to-use-my-custom-qt-widget-in-python/31327/2 "2023-08-24T13:30:35Z")

</div>

> I create a Qt widget named ‘MyWidget’

Are you asking how to reuse a Qt widget written in C++ from Python ?

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [August 24, 2023, 1:33pm UTC](https://discourse.slicer.org/t/how-to-use-my-custom-qt-widget-in-python/31327/3 "2023-08-24T13:33:37Z")

</div>

This is fully possible, and I have done it many times. The question is what step you are missing, which we cannot tell from this much information. Please describe your approach in as much detail as possible. How did you add the widget and in what project? What files does it include? Did you add all of them to CMakeLists? Did you build the code? How do you start Slicer? Things like this… Thanks.
