# How to really select a qComboBox programmly

**URL:** <https://discourse.slicer.org/t/how-to-really-select-a-qcombobox-programmly/28259>\
**Category:** Development\
**Tags:** qt\
**Created:** [March 9, 2023, 2:23pm UTC](https://discourse.slicer.org/t/how-to-really-select-a-qcombobox-programmly/28259 "2023-03-09T14:23:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WilliamLambert1205](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/williamlambert1205/32/16334_2.png) [@WilliamLambert1205](https://discourse.slicer.org/u/WilliamLambert1205)\
**Post date:** [March 9, 2023, 2:23pm UTC](https://discourse.slicer.org/t/how-to-really-select-a-qcombobox-programmly/28259/1 "2023-03-09T14:23:52Z")

</div>

Hi,everyone. I’m trying to using code to substitute a series of mouse clicking and I get into trouble, please guide me.  
In the first step, I need to select the first item in ‘OutputVolume’.(‘OutputVolume’ is a qComboBox).  
In the second step, I need to select another, it means the second item in ‘OutputVolume’.

The apperance of this problem is when I click every qComboBox and select, every thing goes right, however, when I set the qComboBox programmly, it seems like I haven’t changed the ‘OutputVolume’ though the words showed is changed. And the result by program is same as when I only do the first step by clicking, but skip the second step.

I guess the problem is, in the second step, these 2 lines below,  
OutputVolume=SimpleFiltersWidgetWhole[7]  
OutputVolume.setCurrentNodeIndex(1)  
which seems to only change what is showed visually in the qComboBox, but don’t truely get the item selected. In other word, it seems I need one more ‘click’ on the item to get it selected.

I loaded 2 .nii as volume.

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

my code below

#First flip  
slicer.modules.simplefilters.widgetRepresentation()  
slicer.modules.SimpleFiltersWidget.searchBox.setText(‘FlipImageFilter’)  
SimpleFiltersWidgetWhole=slicer.modules.SimpleFiltersWidget.filterParameters.widgets  
InputVolume=SimpleFiltersWidgetWhole[0]  
InputVolume.setCurrentNodeIndex(0)  
FlipAxesSpinbox1=FlipAxesSpinbox[1]#SagittalplaneFlip  
FlipAxesSpinbox1.setValue(1)  
FlipAxesSpinbox2=FlipAxesSpinbox[2]#CoronalplaneFlip  
FlipAxesSpinbox2.setValue(0)  
FlipAxesSpinbox3=FlipAxesSpinbox[3]#HorizontalplaneFlip  
FlipAxesSpinbox3.setValue(0)  
#setFlipAboutOriginchecked  
FlipAboutOrigin=SimpleFiltersWidgetWhole[4]  
FlipAboutOrigin.setChecked(1)  
#setLabelMapchecked

LabelMap=SimpleFiltersWidgetWhole[9]  
LabelMap.setChecked(0)  
slicer.modules.SimpleFiltersWidget.applyButton.clicked()

#Secondflip  
InputVolume=SimpleFiltersWidgetWhole[0]  
InputVolume.setCurrentNodeIndex(1)  
OutputVolume=SimpleFiltersWidgetWhole[7]  
OutputVolume.setCurrentNodeIndex(1)  
FlipAxes=SimpleFiltersWidgetWhole[2]#FlipAxes  
FlipAxes.coordinates  
FlipAxes.children()  
FlipAxesSpinbox=FlipAxes.children()

FlipAxesSpinbox1=FlipAxesSpinbox[1]#SagittalplaneFlip  
FlipAxesSpinbox1.setValue(1)  
FlipAxesSpinbox2=FlipAxesSpinbox[2]#CoronalplaneFlip  
FlipAxesSpinbox2.setValue(0)  
FlipAxesSpinbox3=FlipAxesSpinbox[3]#HorizontalplaneFlip  
FlipAxesSpinbox3.setValue(0)

#setFlipAboutOriginchecked

FlipAboutOrigin=SimpleFiltersWidgetWhole[4]

FlipAboutOrigin.setChecked(1)  
#setLabelMapchecked  
LabelMap=SimpleFiltersWidgetWhole[9]  
LabelMap.setChecked(1)

slicer.modules.SimpleFiltersWidget.applyButton.clicked()
