# How to use signals and slots in Slicer 3d?

**URL:** <https://discourse.slicer.org/t/how-to-use-signals-and-slots-in-slicer-3d/14013>\
**Category:** Support\
**Created:** [October 13, 2020, 2:28pm UTC](https://discourse.slicer.org/t/how-to-use-signals-and-slots-in-slicer-3d/14013 "2020-10-13T14:28:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 13, 2020, 2:54pm UTC](https://discourse.slicer.org/t/how-to-use-signals-and-slots-in-slicer-3d/14013/2 "2020-10-13T14:54:08Z")

</div>

A previous post of mine mentioned some about basics of using Qt signals and slots with python.

> [@Dynamically Updating UI](https://discourse.slicer.org/t/dynamically-updating-ui/13801/6):
>
> Doing some like a=qt.QPushButton() is already the python interface that you can use in Slicer to interact with Qt which is C++ based. Slicer uses [PythonQt](https://mevislab.github.io/pythonqt/) and not [PyQt](https://riverbankcomputing.com/software/pyqt/intro). They are similar in syntax, but with different licensing. How are you currently connecting the button press to updating the label? I generally connect actions using the newer style of a=qt.QPushButton() a.clicked.connect(slotName)

**Essentially the syntax is something like {object}.{signal\_name}.connect({slot\_name}).**

So something that is based on QProgressBar will have [these signals](https://doc.qt.io/qt-5/qprogressbar.html#signals) such as valueChanged. Therefore

```python
def printMyNewValue(value):
  print("The progress bar value is now: {}".format(value))

import qt
progress_bar = qt.QProgressBar()
progress_bar.setMaximum(10)
progress_bar.valueChanged.connect(printMyNewValue)
progress_bar.setValue(4) # will then print "The progress bar value is now: 4"

```

---

_[View the full topic](https://discourse.slicer.org/t/how-to-use-signals-and-slots-in-slicer-3d/14013)._
