Of course,
void SliderDelegate
::setEditorData(QWidget *editor,
{
switch( index.column() )
{
case 1:
{
int value = index.model()->data(index, Qt::DisplayRole).toInt();
QSlider *spinBox
= static_cast<QSlider
*>
(editor
);
spinBox->setValue(value);
break;
}
case 0:
{
QString value
= index.
model()->data
(index, Qt
::DisplayRole).
toString();
QCheckBox *checkbox
= static_cast<QCheckBox
*>
(editor
);
if( value == "1" )
checkbox->setCheckState( Qt::Checked );
else
checkbox->setCheckState( Qt::Unchecked );
break;
}
}
}
void SliderDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
switch( index.column() )
{
case 1:
{
int value = index.model()->data(index, Qt::DisplayRole).toInt();
QSlider *spinBox = static_cast<QSlider*>(editor);
spinBox->setValue(value);
break;
}
case 0:
{
QString value = index.model()->data(index, Qt::DisplayRole).toString();
QCheckBox *checkbox = static_cast<QCheckBox*>(editor);
if( value == "1" )
checkbox->setCheckState( Qt::Checked );
else
checkbox->setCheckState( Qt::Unchecked );
break;
}
}
}
To copy to clipboard, switch view to plain text mode
Looks like it is a simple case of checking whether value is zero in case 1.
Kind regards,
Steve
Bookmarks