Data driven selection in Qt view

46 views Asked by At

I am looking for an elegant way to change the selection in a Qt TreeView based on the data of the underlying model. So my dynamic data contains information about the currently active element which should be selected in the TreeView.

Background: I have a setup with a 3d viewer for a bunch of objects and a Qt TreeView that lists the objects. The user should be able to select objects by klicking them either in the TreeView or in the 3d viewer. The 3d viewer is non-Qt code and modifies the data directly and sets the a flag indicating the selection.

I implemented a dataModel and a selectionModel (as I have to synchronize two views on the data).

My current idea is to emit a signal from the dataModel to the selectionModel to modify the selection when the data has changed. But this seems awkward to me...

Is there a recommended Qt way of doing this?

0

There are 0 answers