dirModel=new QSqlRelationalTableModel(this);
dirModel->setTable("ecm_doc");
dirModel->setFilter(QString("creatoruserid='%1' and parentid='%2'").arg(userid).arg(parentid));
dirModel->select();
dirView=new QTableView(this);
dirView->setItemDelegate(new DirDelegate(this));

dirView->setModel(dirModel);
dirView->setSelectionMode(QAbstractItemView::SingleSelecti on);

showIcon();

void DirTree::showIcon()
{
int rowCount = dirModel->rowCount();
for(int row = 0; row < rowCount; row++)
{
//here is a test.
QModelIndex index = dirModel->index(row, 1);
QIcon folderIcon(style()->standardPixmap(QStyle::SP_DirClosedIcon));
dirModel->setData(index, folderIcon, Qt:ecorationRole);
}
}