title: Overwrite data and setData in Qt's QFileSystemModel
body: <p>What I'am trying to do:
  Overwrite QFileSystemModel's setData and data to implement Caching of pictures in the shown directory.</p>
  
  <p>I use a QListView for testing purpose.</p>
  
  <p>Here is the relevant code:</p>
  
  <p>My Class with QFileSystemModel as parent: </p>
  
  <p>.h-file:</p>
  
  <pre><code>#ifndef QPICSINFILESYSTEMMODEL_H
  #define QPICSINFILESYSTEMMODEL_H
  
  #include &lt;QFileSystemModel&gt;
  #include &lt;QCache&gt;
  #include &lt;QDebug&gt;
  
  /* This Model holds all Picturefiles with a cached QPixmap of
   * them.
   */
  
  class PicsInFileSystemModel : public QFileSystemModel
  {
  public:
      PicsInFileSystemModel();
      QVariant data (const QModelIndex &amp; index, int role);
  private:
      QCache&lt;qint64,QPixmap&gt; *cache; //Cache for the pictures
  
  };
  
  #endif // QPICSINFILESYSTEMMODEL_
  </code></pre>
  
  <p>.cpp-file:</p>
  
  <pre><code>#include "PicsInFileSystemModel.h"
  
  PicsInFileSystemModel::PicsInFileSystemModel()
  {
      QStringList myFilter;
      this-&gt;setFilter(QDir::Files | QDir::AllDirs);
      this-&gt;setRootPath(QDir::rootPath());//QDir::homePath());
      myFilter &lt;&lt; "jpeg" &lt;&lt; "jpg" &lt;&lt; "png";
      //this-&gt;setNameFilters(myFilter);
  }
  
  /* Reimplement data to send the pictures to the cache */
  QVariant PicsInFileSystemModel::data ( const QModelIndex &amp; index, int role = Qt::DisplayRole ) {
      qDebug() &lt;&lt; "index: " &lt;&lt; index &lt;&lt; "role: " &lt;&lt; role;
  
      return ((QFileSystemModel)this).data(index,role);
  }
  </code></pre>
  
  <p>How I call the object:</p>
  
  <pre><code>pics = new PicsInFileSystemModel;
  form-&gt;listViewPictures-&gt;setModel(pics);
  form-&gt;listViewPictures-&gt;setRootIndex(pics-&gt;index(
          "mypath"));
  </code></pre>
  
  <p>So here is the question: In my opinion I should see many debug outputs when the View access the Model. But there is nothing. Has anyone an idea what I'am doing wrong?</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:
  The answers work. I also had to change this</p>
  
  <pre><code>return ((QFileSystemModel)this).data(index,role); 
  </code></pre>
  
  <p>into</p>
  
  <pre><code>QFileSystemModel::data(index,role))
  </code></pre>