Qtablewideget detect change after click.



  • Hi,

    I have a vector list of object id and names etc. If we detect an object listed in that vector space we will add this item to the qtablewidget . than we want to change or edit the detail from qtablewidget.

    If we use change detect it is detecting the first change which means putting in the list from detection of object. But we want to first click the cell and change it then ENTER . we want to detect this.

    Is this possible ?

    thnx


  • Lifetime Qt Champion

    Hi,

    Do you mean what is provided by QTableWidget::itemChanged ?



  • Yes, the problem here our QTableWidget is empty in the beginning. And we are filling it automatically when we detect new object from the video. Thats is also detected as a change.

    what we want to do is ; we want to edit qTablewidget if the label is incorrect. But detect change also detect for first insert / add.

    What we try a workaround is first detect doubleclick and set a t_row t_column and than check if edited row and column equals to the t_row , t_column. So we understanda user changed somethin not program.

    any other way ?


  • Qt Champions 2016

    Hi
    You can use blockSignals(true/false); on the qtablewidget when you fill data from code to avoid it triggering
    change actions alike when user changes.



  • I'm afraid blocking signals might prevent the view from updating.

    And we are filling it automatically when we detect new object from the video.

    When you fill it automatically, before adding the QTableWidgetItem call item->setData(Qt::UserRole+88,true)

    then in the slot connected to itemChanged do

    if(item->data(Qt::UserRole+88).toBool()){
    const QSignalBlocker blocker(item->tableWidget());
    item->setData(Qt::UserRole+88,QVariant());
    return;
    }
    

    P.S.
    Starting from Qt 5.11 there will be a more elegant solution to this problem


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.