# C++: How to select an object in the pipeline browser

**URL:** https://discourse.paraview.org/t/c-how-to-select-an-object-in-the-pipeline-browser/2401
**Category:** Development
**Created:** [August 10, 2019, 8:22am UTC](https://discourse.paraview.org/t/c-how-to-select-an-object-in-the-pipeline-browser/2401 "2019-08-10T08:22:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mvillegas](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@mvillegas](https://discourse.paraview.org/u/mvillegas)
#### Post date: [August 10, 2019, 8:22am UTC](https://discourse.paraview.org/t/c-how-to-select-an-object-in-the-pipeline-browser/2401/1 "2019-08-10T08:22:14Z")

</div>

Hello,

this is likely very simple but I’ve decided to ask here after not being able to solve it. What I want to do is to mark an object in the pipeline browser as selected, given its pqPipelineSource pointer. I’m working inside the pqOpenVRControls class, where the reverse example of getting a pqPipelineSource\* based on selection already exists.

My approach looks somewhat like this:

> QItemSelectionModel\* smodel = this-\>Internals-\>pipelineBrowser-\>getSelectionModel();  
> QModelIndex index = smodel-\>model()-\>index(0,0); //Tried a lot of stuff here  
> const pqPipelineModel\* model = this-\>Internals-\>pipelineBrowser-\>getPipelineModel(index);  
> QModelIndex selindex = model-\>getIndexFor(source); // source being the provided pqPipelineSource\*  
> smodel-\>select(selindex, QItemSelectionModel::SelectionFlag::Select);

A common error I get is that I’m using a QModelIndex from a different model, but I’m not sure how to solve this.

Thank you in advance.

---

<div class="post-metadata">

### Author: ![Joachim\_Pouderoux](https://discourse.paraview.org/user_avatar/discourse.paraview.org/joachim_pouderoux/32/38_2.png) [@Joachim\_Pouderoux](https://discourse.paraview.org/u/Joachim_Pouderoux)
#### Post date: [September 3, 2019, 8:48pm UTC](https://discourse.paraview.org/t/c-how-to-select-an-object-in-the-pipeline-browser/2401/2 "2019-09-03T20:48:10Z")

</div>

Hi,

You could just set you source as the active source (`pqActiveObjects::instance().setActiveSource(pqsource));`) and the pipeline widget will automatically set it as the active/selected pipeline source.

Best,  
Joachim
