• 4977阅读
  • 1回复

请教treeview delegate 控件的问题 [复制链接]

上一主题 下一主题
离线samp
 
只看楼主 倒序阅读 楼主  发表于: 2008-04-29
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
我定义了一个treeview,当使用标准model,即 QStandardItemModel model(4, 4); 的时候,可以delegate 一些控件,但是当我使用其他一些model时,比如Foundations_of_Qt_Development这本书的一个例子中的model,就无法delegate 空件了。请问这是为什么?谢谢!!

这是那个例子中定义的model
class ObjectTreeModel : public QAbstractItemModel
{
public:
  ObjectTreeModel( QObject *root, QObject *parent = 0 );
 
  Qt::ItemFlags flags( const QModelIndex &index ) const;
  QVariant data( const QModelIndex &index, int role ) const;
  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
  int rowCount( const QModelIndex &parent = QModelIndex() ) const;
  int columnCount( const QModelIndex &parent = QModelIndex() ) const;
 
  QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
  QModelIndex parent( const QModelIndex &index ) const;
 
private:
  QObject *m_root;
};

delegate 的代码是参照examples\itemviews\spinboxdelegate中的,我就不贴上来了
离线samp
只看该作者 1楼 发表于: 2008-04-29
我发现examples\itemviews\spinboxdelegate 这个例子中使用的model 就是QStandardItemModel model,看来使用相关的delegate代码对其他model似乎不太兼容,大家有什么treeview  delegate控件的例子么?在网上基本都是tableview的。
快速回复
限100 字节
 
上一个 下一个