Pergunta

i have subclass qstyleditemdelegate

in col==1 and col==2 i have create Qdoublespinxboxs, i want to emit valuechanged of my

Qdoublespinxbox, to calculate a subtotal ( col1 * col2 )

means : ouside the delegate

every time the value of Qdoublespinxbox changed i will update the value subtotal

Foi útil?

Solução 2

you can add signal to your QStyledItemDelegate subclass, emitted in setModelData() reimplementation. Signal should have information about new value and possible locate of data. In other class catch that signal and update the value subtotal.

Outras dicas

Create a slot in your delegate class:

void My_delegate::valueChanged() {
  emit commitData(sender());
}

In My_delegate::createEditor connect spinbox's valueChanged() signal to My_delegate::valueChanged.

Be sure that setEditorData method is implemented properly in your delegate class. In this method you should set model's data based on spinbox's value. This method will be called automatically when you emit commitData.

Now when user edits a spinbox, data comes to the model immediately. You can use the model's dataChanged signal to track data changes.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top