[SOLVED] how to reset the combobox to its default state?
-
in the qt designer, i have added some items to the combobox. when the user selects an item from the combobox, i would like that item to be deselected and to display the first item at the top of the combobox again. i am asking if there is a way to reset the combobox back to its default state.
-
you mean, when the user click an item, you want to re-order the items and to put the selected one as the first index?
-
no. i ment that the combobox should look the way it was when the user first sees it. the scroll bar back up to the top and the first item is seen.
-
So... you mean, that you would like to confuse the user into thinking your application is broken because the item he just selected suddenly is not selected anymore?
-
The pure purpose of a combo box is to have the user select an option. Your UI design is awfully broken.
-
no. you miss understand Volker, and Andre. the user selects and item in the combobox and the event is triggered. after the event, the combobox is reset to the default state. that is what i am trying to do.
-
if i understand it correctly , you are looking for setCurrentIndex ( int index ). That is, after every selection, the combobox shows the particular item, instead of the selected item.
And if you reset this way with value -1 , the selection will be none. -
ok. i thought that setCurrentIndex would set the index and not the item text. thank you Rahul Das. i marked this topic as solved :)
-
[quote author="kalster" date="1323577768"]no. you miss understand Volker, and Andre. the user selects and item in the combobox and the event is triggered. after the event, the combobox is reset to the default state. that is what i am trying to do.[/quote]
I understood it exactly this way and I stand that this is a horrible UI design. I as a user would be upset.
If I needed such a functionality, I would go with a context menu or a [[Doc:QToolButton]] with a menu. That looks more suitable for what you want to do and does not fool the user.
-
i have two comboboxs, one is for the user name and the other is for the user locations. when a different user name is selected, the user location combobox needs to change. i was asking how to change the user location but i understand how now.
i would agree that this is a bad ui design if i was using one combobox but i am using two comboboxs to function together.
-
Of course that make sense in that constellation. Sorry if it sounded a bit harsh before.
-
that's ok Volker. I was just not too clear enough in this topic :)