我的自定义委托项(QTableWidget的项)需要知道父对话框中的变量 我怎么能找回它?
QWidget* CustomDelegate::createEditor ( QWidget* parent , const QStyleOptionViewItem& option , const QModelIndex& index ) const
{
QWidget* delegate = QItemDelegate::createEditor(parent, option, index);
if(index.column() == 1)
{
QDoubleSpinBox* spin = new QDoubleSpinBox(parent);
spin->setDecimals(1);
...
}
else if(index.column() == 2)
{
if (???VARIABLE FROM PARENT DIALOG???)
{
QLineEdit* timeObj = new QLineEdit(parent);
timeObj->setInputMask("99");
QRegExp rx("[0-9\\s][0-9\\s]");
QValidator *myvalidat = new QRegExpValidator(rx, 0);
timeObj->setValidator(myvalidat);
return timeObj;
}
QLineEdit* timeObj = new QLineEdit(parent);
timeObj->setInputMask("99:99");
....
}
}
else
return delegate;