# Trigger Reload Files from within property widget code

**URL:** https://discourse.paraview.org/t/trigger-reload-files-from-within-property-widget-code/3965
**Category:** Development
**Created:** [April 4, 2020, 9:01am UTC](https://discourse.paraview.org/t/trigger-reload-files-from-within-property-widget-code/3965 "2020-04-04T09:01:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [April 4, 2020, 9:01am UTC](https://discourse.paraview.org/t/trigger-reload-files-from-within-property-widget-code/3965/1 "2020-04-04T09:01:02Z")

</div>

Is there a way how the code of a property widget can trigger a “reload files” (like what the user can do with F5 in ParaView)?

Because I have a button there in a property widget related to a specialized file reader that allows to do changes in the input file - and afterwards it would be nice if the user would not be required to press F5 (and possibly forget!).

For some other widget I already found a way to automatically press “Apply”, but this is a bit “hackish”: First get the property panel object through the means of Qt (findChild - starting with the main window etc. -, then call the “Apply” function). Maybe such kind of approach would be possible as well!?

Anyway, if there is a more elegant way I would prefer it. So any hints are welcome!

---

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [April 5, 2020, 9:26am UTC](https://discourse.paraview.org/t/trigger-reload-files-from-within-property-widget-code/3965/2 "2020-04-05T09:26:26Z")

</div>

I see that with the following code I am getting the desired effect:

```
QMainWindow* mainWindow = qobject_cast<QMainWindow*>(pqCoreUtilities::mainWidget());
QList<QAction*> aList = mainWindow->findChildren<QAction*>("actionReloadFiles");
if(!aList.isEmpty())
{
    rfa = aList.first();
	rfa->trigger();
}

```

Maybe I should put my hesitations about “hackish code” aside and just do it 😉

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [April 5, 2020, 3:36pm UTC](https://discourse.paraview.org/t/trigger-reload-files-from-within-property-widget-code/3965/3 "2020-04-05T15:36:24Z")

</div>

`pqReloadFilesReaction::reload()` is a static function, so you can just call it directly instead.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 6, 2020, 6:30am UTC](https://discourse.paraview.org/t/trigger-reload-files-from-within-property-widget-code/3965/4 "2020-04-06T06:30:08Z")

</div>

> [@cobo](#):
>
> For some other widget I already found a way to automatically press “Apply”, but this is a bit “hackish”: First get the property panel object through the means of Qt (findChild - starting with the main window etc. -, then call the “Apply” function).

Here is the “right” way to Apply the pipeline, filter by filter.

```
filter->getProxy()->UpdateVTKObjects();
filter->updatePipeline();
filter->setModifiedState(pqProxy::UNMODIFIED);

```

---

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [April 6, 2020, 9:12am UTC](https://discourse.paraview.org/t/trigger-reload-files-from-within-property-widget-code/3965/5 "2020-04-06T09:12:34Z")

</div>

Thanks for both hints!
