[SOLVED] how to reset the combobox to its default state?
-
wrote on 10 Dec 2011, 07:03 last edited by
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.
-
wrote on 10 Dec 2011, 07:11 last edited by
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?
-
wrote on 10 Dec 2011, 08:51 last edited by
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.
-
wrote on 10 Dec 2011, 09:50 last edited by
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?
-
wrote on 10 Dec 2011, 13:51 last edited by
The pure purpose of a combo box is to have the user select an option. Your UI design is awfully broken.
-
wrote on 11 Dec 2011, 04:29 last edited by
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.
-
wrote on 11 Dec 2011, 06:05 last edited by
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. -
wrote on 11 Dec 2011, 08:33 last edited by
ok. i thought that setCurrentIndex would set the index and not the item text. thank you Rahul Das. i marked this topic as solved :)
-
wrote on 11 Dec 2011, 12:31 last edited by
[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.
-
wrote on 11 Dec 2011, 23:46 last edited by
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.
-
wrote on 12 Dec 2011, 00:18 last edited by
Of course that make sense in that constellation. Sorry if it sounded a bit harsh before.
-
wrote on 12 Dec 2011, 00:27 last edited by
that's ok Volker. I was just not too clear enough in this topic :)
1/12