16,173
社区成员
发帖
与我相关
我的任务
分享
deviceList_Model = new DeviceListTableModel;
switch_StyleItemDelegate = new SwitchDelegate(this);
dev_TableView->setItemDelegate(switch_StyleItemDelegate);
dev_TableView->setModel(deviceList_Model);
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
QWidget* SwitchDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
qDebug()<<"23333";
if(index.column() == 3)
{
SwitchButton* btn = new SwitchButton(parent); //这个是自定义的按钮
return btn;
}
else
return QItemDelegate::createEditor(parent,option,index);
}
qDebug()<<"23333";
qDebug()<<"这里是构造函数";
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
void setEditorData(QWidget* editor, const QModelIndex& index) const;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;