I want to check the state of some list in my program every time when a user opens Combobox and if the list was changed change the string list in Combobox. I find that I can reimplement showPopup but I can't think of a way to do it with this function.
How I should do this?
Related
I'm using Qt 5.12. I want to remove all items from combo Box at a time. is there any procedure to remove all items at a time without removing one by one index.
If you take a look at https://doc.qt.io/qt-5/qcombobox.html you will see the function clear().
Function description:
“Clears the combobox, removing all items.
Note: If you have set an external model on the combobox this model will still be cleared when calling this function.”
I have an editable QComboBox containing a list of ID numbers.
The ID numbers represent devices attached to the system. The devices are frequently added and removed at runtime.
The intent of the editable combo box is to contain, in its list, the list of IDs currently attached, for easy selection, but at the same time allow the user to manually enter IDs of devices not currently present. Also, it's valid to enter an empty string for the ID.
Basically I want to provide the user with a way to enter an arbitrary (or no) ID, with the added bonus of a quick selection of devices currently attached (which changes at runtime).
I am not currently using a list model to maintain the list, I'm just using the QComboBox's add and remove functions.
I need the selection to not change if devices are added or removed. However, I'm running into the following problems:
When the currently entered ID (either manually or by list selection) is removed from the list, the selection is changed to another ID in the list.
When the list is empty and an ID is entered manually, or no ID is entered at all, the selection is changed when an ID is added to the list.
Is there a way to make it so that adding and removing items from the combo box never, ever modifies the selection in the edit box? Or even some other UI element that accomplishes my goal?
Before updating the combo box, save the currently selected ID (or the blank string) to a temp. variable. After modifying the combo box contents, check if that ID still exists in the combo box (e.g. with findText()). If it does, select it with setCurrentIndex(). If it does not, set it with setCurrentText() or setEditText().
I have at QComboBox some items (added by program - it is a lot added items (about 1000))
So i make combobox editable -> then it is simple to find a correct item. (For example if i want to find item called "My Example" i write in combobox "MY" and i get items which starts from "MY" )
But when i write somethink other than it is in combobox, combobox add this item.
I dont want it, i want only to:
Can select only ITEMS added by Program
Block adding custom items
When i write something like "MY" but dont select item "My Example" because there is "My Example","My Example2"
And press push button to accept my choice - then how to check that i choice item from items added by Program not written and not finished by User?
Set these QComboBox properties to the following:
1. Set setEditable to true.
2. Set insertPolicy to NoInsert.
3. Set currentIndex to -1 to make it empty at start.
Then process currentIndexChanged signal which will be sent only when a certain item from the list is chosen.
Is there a way to manipulate the List displayed by the OptionMenu in respect to what the user has currently selected?
For example, let's say I have a list - ["A","B","C"].
If the user currently selected A then if he clicks the optionmenu with A currently selected, what he will see in the list is not the original list but only B and C.
If he switches his answer from, let's say, A to B, then now, he will only see A and C in the OptionMenu.
And the same will follow if he chose B or C.
Thanks!
The OptionMenu widget is a button that shows a dropdown menu when pressed. You might do better to use a ttk.Combobox instead as that is a more modern UI element and you can very simply configure the values configuration item.
You can configure the attached menu at runtime. You access the menu using optionmenu['menu'] and you can then query items on the menu optionmenu['menu'].entrycget(0, 'label') or use entryconfigure to modify the items. Or you can delete items optionmenu['menu'].delete(index) and add new items. See the menu documentation for hints on manipulating the menu entries.
I created a Combobox with CreateWindowEx. Everything goes well. But I would like to make a final feature: AutoSuggestion. The Combobox is used to do search text in a document, hence at some point, it have items that are the strings a user searched. The AutoSuggestion should be: drop down the list of items, find those items that begin with the string that a user typed in the edit control, but do not select one of them, do not display all other items, and finally do not change select item when keydown or keyup occurs, only highlight the item and select only when a user press Enter. Do you have any idea how to accomplish this task?
It sounds like you want Autocomplete functionality.