click feature in Qt - qt

I just want to clarify, weather the feature is present or not in Qt.
The scenario is like this,
I have a list view with items, I want to place the icon to the listview when the item is selected.
The selection I mean is, first time when I click item should be selected, next time if I click the same item then it should display some icon. Please note
It is not the double click. again if do select some other item same feature should continue
So is there any feature which handles this feature by default, any property or flag which I need to set to listview to behave like this or manual implementation
Is required for this.

No problem (: Now I understand what you mean... So if you click on an item it should be selected (for example highlighted in blue) and then when you click on this item again, an icon should be displayed.
I can't think of a regualar way to do this, there is no such flag or something.
The easiest way I can think of would be to store the index in a QList when you select it. And when you deselect it, you delete the index from the list. SO, when you click on an item you can check if it is in that list and if so you can display your icon.
Another way would be to create your own type of QModelIndex. Everytime, this index is selected, you set a bool like is_already_selected on true. When clicking on this item again you check this bool and then decide whether an icon should be displayed or not.
For further information, see: QListView, QAbstractItemView::currentIndex, QModelIndex

Related

Detect selected row with force touch watchkit

Is it possible to detect selected row index with force touch? Did force touch in tableView current row is highlighted. But i can't take info about him when context menu appears. TableView method -didSelectRowAtIndex: not called with this event.
The only thing you can handle programmatically with the Force Touch is the Context Menu and this menu is associated with a specific controller, more information you will find following the link.
About the row highlighting: When you start tapping the system doesn't know what the real action is - the regular touch or the force one. So it is starting to highlight a specific area and only later find out what was the action.

How to: Allow for a ListBox to have no selection

I am wanting to allow for a user to deselect all values in a ListBox. Normally, when the user deselects all but one item, that one item cannot be deselected. I want to make it so it can be.
Thanks
Essentially I'm aware of two ways of doing this:
Add an empty item to the list. You can even name this item "None" or something similar. Using a text has the additional advantage that it informs the user.
Use JavaScript to unselect the item that is clicked if it is the last item.
Note, either way, you change the default behavior of the listbox, which is what users are accustomed to. Changing the default behavior is generally not a good idea, which is why I would go for option (1) being the clearest towards your users.

How to loop QListView item selection

How can I make QListView item selection loop from bottom item to top (by pressing navigation key, down) and from top item to bottom (by pressing navigation key, up)? Is there a flag to be defined or some other way? My listview is in IconMode I wanted the selection to go to next row's 1st item when I've reached the end of a row.
Thanks
Its Default behavior provided by the list view for iconic mode.
in order to achieve your requirement, you need to handle it manually.
i.e you will be having the count of items in a row, once you reach the last item handle the right navigation key press event, then focus it back to the first element of the same row..
to get the navigation keypress event, either you install event filter or ovveride the keypress event function.

List Component that acts as if control was permanently pressed

I have a list control and i want the user to be able to select many items at a time. Thus I want it to act that if the control key is pressed while he is clicking. Eg if he clicks on a selected row it should become unselected and if he clicks on a unselected row it should become selected.
Do you have any idea how to do this?
Thanks,
Dennis
If you want to follow standard UI Precedent; then set allowMultipleSelection to true and teach your users to use the control and/or shift button to select multiple items.
If you want to select multiple items without having the using press the shift or control button you'll have to extend the List class. I did a sample a while ago using the DataGrid:
http://www.flextras.com/blog/index.cfm/2009/7/23/Flextras-Friday-Lunch--Episode-22--07032009--Auto-Select-DataGrid
http://www.flextras.com/labs/AutoSelectDataGrid/
http://www.flextras.com/labs/AutoSelectDataGrid/srcview/index.html
You can probably use the same technique with a List. But, I don't recommend this approach.

Can I make QCompleter complete inline and show a popup

Qt 4.5 (PyQt 4.6.1)
I'm looking for a widget similar to a QComboBox that automatically filters its entries to the ones starting with the input in the text field. There are around 300 items in the combo box.
I've tried two approaches:
QLineEdit with QCompleter
Advantages
Filtering the items works.
Disadvantages
Doesn't show a popup if the text field is empty.
Doesn't do inline completion.
Allows to insert items not in the list.
Editable QComboBox with insertion set to no
Advantages
Nice popup
Completes inline in the text field.
Disadvantages
No filtering
Input is only possible in either the text field or the popup. Clicking on the popup doesn't select the best-matching item in the popup.
What I need
A popup to select the items.
Slow tippers should be able to start tipping the name of an item and the popup switches to the best matching one.
Preferably I should filter the items so that only partially-matching items are shown.
Concerning you first try with QLineEdit, you can set the completionMode to do it inline.
For your second try, you can add a QCompleter object to you QCombBox in order to filter your items as you want.The QCompleter member of the QComboBox is to offer an easy way to use QCompleter.
Anyway, if you are not satisfied with this method, you can manage a QCompleter object by yourself. This allows you to choose how item list is display (using any views) and to define items order in the list. See basic QCompleter details.

Resources