首页| 论坛| 消息

标题:大家注意过setItemDelegateForColumn这个函数没有?
作者:realequ
日期:2007-05-25 10:43
内容:

在4.1以前QTableView类中只有setItemDelegate这个函数
4.2以后,出现了setItemDelegateForColumn(setItemDelegateForRow)这两个函数。
但是,我在使用的时候,发现这两个函数是没有起作用。
有使用过这两个函数的没有?
给谈谈经验吧。


#1 [realequ 05-25 10:52]
这里也发现这个问题了。不知道是不是函数真的有问题。
http://trolltech.com/developer/task-tracker/index_html?id=132870+&method=entry
132870 - setItemDelegateForColumn does not work
DescriptionsetItemDelegateForColumn and tableView.setItemDelegateForRow does not work.
Reproducible with the qspinbboxdelegate example and replacing the main function with:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model(4, 2);
QTableView tableView;
tableView.setModel(&model);
SpinBoxDelegate delegate;
//does not set a spin box delegate for colum or row
tableView.setItemDelegateForColumn(2,&delegate);
tableView.setItemDelegateForRow(2,&delegate);
//this does work as expected
// tableView.setItemDelegate(&delegate);
tableView.setWindowTitle(QObject::tr("Spin Box Delegate"));
tableView.show();
return app.exec();
}
#2 [jasmine007 07-26 10:26]
用是用过这个
但是我用的很简单
实现的功能是在table中的某一列都是下拉后是 日期和时间的组合对话框
table->setItemDelegateForColumn(3,&dateDelegate);
table->setItemDelegateForColumn(4,&dateDelegate);
表示第三列和第四列为该对话框
#3 [jasmine007 07-26 10:29]
但是不知道是不是我用的不好
它只能调节日期的数据并没有时间的
#4 [hailler 10-29 09:19]
因为我在tableview里面只用了一个delegate ,所有用了一个耍赖的办法,实现了在只读行里面,判断改行为只读,不可复制的效果。

QModelIndex index=tableview->currentIndex();
QAbstractItemDelegate *itemdelegate= tableview->itemDelegateForRow(index.row());
if(itemdelegate)
return;

回复 发表
主题 版块