The model gets automatically destroyed when going out of scope. Allocate it on the heap:
Qt Code:
  1. FileModel* fmodel = new FileModel(this);
  2. QTableView *table = new QTableView(this);
  3. table->setModel(fmodel);
To copy to clipboard, switch view to plain text mode 
PS. Have you noticed QDirModel?