Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

cumulative value in tablewidget



  • greetings all,

    i'm a student who just learned Qt.
    i got a project to build a program for warehouse data inventory. i use MySQL workbench in this project.

    so, i have this table preview
    0_1553063718670_62887741-a4d1-4263-9219-053b3f5b8beb-image.png

    everytime i input data on column "masuk" and "keluar" it just replace the value. I want every time I input data in the column "masuk" and "keluar, the value is added from the previous value and so on.

    if anyone knows the answer, i would be appriciate it



  • @farhanrbn

    That is not an issue of Qt. That need to be part of the logic behind where you define what has to be changed with some input to the table. This could be possibly done in MySQL or in the classes and objects you have programmed to bring up the information.
    AFAIK there is no direct help from Qt classes.
    Basically you can find out that something has been changed through a signal emitted by the field where you changed. In the associated slot you can have all the logic you want.


  • Lifetime Qt Champion

    Hi,

    If I understand your requirements correctly, you will have to implement a custom QStyledItemDelegate and modify the setModelData method to do the addition there.

    Be sure to also implement a custom editor so that it will be clear that you are doing something special on these columns. Otherwise your application users will be pretty surprised by the difference of behaviour between the different columns.


Log in to reply