我想实现这样一个功能:对着文件/文件夹右键单击,则文件/文件夹处于重命名状态,然后输入新的文件名,输完后,再右键一下,重命名成功。我是这样做的,但不对,提示错误:editing failed
这个功能应该怎么做呀?
Imagewindow::Imagewindow() //构造函数
{
model = new QDirModel ;
list = new QListView(this);
list->setViewMode(QListView::IconMode);
list->setModel(model);
connect(list,SIGNAL(clicked(const QModelIndex &) ),this,SLOT(rename(const QModelIndex &))) ; //clicked是专指右键单击吗?
}
void Imagewindow::rename(const QModelIndex &index)
{
list->setCurrentIndex(index);
list->edit (index ) ;
list->update (index ) ;
//如何表示:再右键一下,重命名成功
}