B
B
becks2015-12-03 20:08:35
Qt
becks, 2015-12-03 20:08:35

How in Qt to select elements in a view by some attribute of real data in the model?

The question sounds silly, I'll try to explain.
There is a model inherited from QAbstractTableModel. It stores inside itself (in various containers) 3 types of mixed data (for example, groups, objects, sources). The object(s) can belong to a group, the source(s) to an object. All this is displayed in one table, which contains all the fields of each type (and if, for example, an object belongs to a group, then the row of the table will contain both its data and the data of this group, if it does not belong, then the corresponding fields of the group will be empty).
Now a request is made to search for all attributes of these types, the results are displayed in a separate dialog (the attribute in which they found, the type, and the value they found). In this plate (dialog) the user clicks on any line and I need to highlight the corresponding entry in the main table. I have the desired id(group, object or source) and type(group, object or source). Based on this data, I can find the desired element in the desired container. What is the easiest way for me to highlight it in the table now? I didn't find such a role (for example, to try to do it via the data() method).
Perhaps somehow selectionModel() can be used...
In short and in other words, often the task is to get real data, having selected rows in the view, here there is an inverse task - I know what data in the model needs to be highlighted (I don’t know their index), but I don’t know how.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question