TreeView programmatic selection Create the UI as follows, drop QTreeView , a couple of QLineEdit s, and a search QPushButton . The UI can look something like the following, with the TreeView on top: Implement the code in mainwindow.h as follows: # ifndef MAINWINDOW_H # define MAINWINDOW_H # include <QMainWindow> # include <QStandardItemModel> # include <QItemSelectionModel> # include <QMap> # include <QModelIndex> QT_BEGIN_NAMESPACE namespace Ui { class MainWindow ; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public : MainWindow ( QWidget * parent = nullptr ) ; ~ MainWindow ( ) ; private : Ui :: MainWindow * ui ; QStandardItemModel model ; QItemSelectionModel * selectionModel ; void init ( ) ; QMap < QString , QModelIndex > searchItemToIndexMap ; private slots : void onSelectionChanged ( const QItemSelect...