# How to get onClick a qt.QComboBox() in a table?

**URL:** <https://discourse.slicer.org/t/how-to-get-onclick-a-qt-qcombobox-in-a-table/10222>\
**Category:** Support\
**Created:** [February 12, 2020, 4:51pm UTC](https://discourse.slicer.org/t/how-to-get-onclick-a-qt-qcombobox-in-a-table/10222 "2020-02-12T16:51:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john123](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/john123/32/6008_2.png) [@john123](https://discourse.slicer.org/u/john123)\
**Post date:** [February 12, 2020, 4:51pm UTC](https://discourse.slicer.org/t/how-to-get-onclick-a-qt-qcombobox-in-a-table/10222/1 "2020-02-12T16:51:35Z")

</div>

I am using `qt.QTableWidget()` with 2 columns. The first column contains checkbox, while the second column is a `qt.QComboBox()`. I want to get the event when the user select the item in the `qt.QComboBox()`. How should I achieve it with Slicer and python?

```auto
        for i in range(4):            
            checkbox = qt.QTableWidgetItem()
            checkbox.setCheckState(False)    
            self.table.setItem(i,0,checkbox)

            self.combo = qt.QComboBox()
            self.combo.addItem("Item 1")
            self.combo.addItem("Item 2")              
            self.combo.setCurrentIndex(0)
            self.table.setCellWidget(0, 1, self.combo)        

```

---

<div class="post-metadata">

**Author:** ![john123](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/john123/32/6008_2.png) [@john123](https://discourse.slicer.org/u/john123)\
**Post date:** [February 13, 2020, 4:00pm UTC](https://discourse.slicer.org/t/how-to-get-onclick-a-qt-qcombobox-in-a-table/10222/2 "2020-02-13T16:00:45Z")

</div>

@lassoan: Could you please give me some hints to do it?

---

<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:** [February 13, 2020, 5:57pm UTC](https://discourse.slicer.org/t/how-to-get-onclick-a-qt-qcombobox-in-a-table/10222/3 "2020-02-13T17:57:05Z")

</div>

Hi John,

As this is a question about using Qt, I would suggest you become familar with the Qt documentation as it is really helpful for determining available signals that a widget might have. I’m recommending this method because this was how I was able to learn! Here’s the link to the signals for a QComboBox - [https://doc.qt.io/archives/qt-5.10/qcombobox.html#signals](https://doc.qt.io/archives/qt-5.10/qcombobox.html#signals). Other widgets can easily be searched with lots of helpful links on the various pages.

Once you know the type of signal to use then using it in python, as available through PythonQt, works like such:

```python
def myIndexChanged(index):
  print("ComboBox index changed to {}".format(index))

combo = qt.QComboBox()
combo.addItems(["Item 1", "Item 2"])
combo.currentIndexChanged.connect(myIndexChanged)

```

Hopefully this example and information helps you get acquainted with using Qt from python 😄
