문제

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

도움이 되었습니까?

해결책 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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top