PDA

View Full Version : How to signal indexChange in a QCombobox cell?



IndikaU
15th September 2011, 03:00
Hi,

I'm using a delegate to QComboBox in table view.How can I emit a signal when user select the item in the combo box?

Here's the code fragment I'm using.

QWidget * DelegateComboBox::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
if ( index.column() == 1 )
{
QComboBox *editor = new QComboBox(parent); //Here the parent is QTableView
editor->addItem("STRING");
editor->addItem("INTEGER");
editor->addItem("DOUBLE");
return editor;6854
}

return QItemDelegate::createEditor(parent, option, index);
}

pkj
15th September 2011, 05:30
QComboBox::currentIndexChanged(index) or QComboBox::currentIndexChanged(const QString &) . But what are you trying to do. Are you trying connect to the signal to save the data? If yes, then use derived QStyleItemDelegate's setModelData function override to set data.