[SOLVED] QtableWidget itemChanged signal problem

  • Hello,

    i have a Qtablewidget populated with editable item for the first row and none editable items for rest of rows

    i use a custom delegate "m_delegate" for that table ( Qcombobox is in the col = 2 )

    i catch when the user make a selection via comboboxx ( text of Qcombobox changed ) to emit a signal , to unlock next row . ( to unlock the next row i make item editable setIemFlags(Qt::itemIsEditable)) ;

    there is no problem until this point . in other side i use


    the after using a debugger is figured out what happen,

    when some changes happened in col == 2 ( Qcombox ) a signal (unlockRow(QmodelIndex ) will be emitted and call unlockNextRow(QModelIndex) to unlock next row

    @ // unlock next
    for(int colToUnlock=0; colToUnlock <ui->newCommandetableWidget->columnCount(); colToUnlock++)
    if(colToUnlock == 1 || colToUnlock == 2 || colToUnlock == 3)
    ui->newCommandetableWidget->item(row,colToUnlock)->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);


    and this force itemChanged(QTableWidgetItem*) signal also, and that it a problem , the program not stop unlocking rows and craches

    the scenario is like ( unlockRow (signal) emitted ) => call unlockNextRow(QmodelIndex) slot ) => unlockNextRow(QmodelIndex) make some changes in table items , and this make QitemChanged(QtableWidgetItem *) signal working witch call also unlockNextRow(QtableWidgetItem *) slot )

    and her is the real problem

    i wanna you can help me to solve this problem

  • Lifetime Qt Champion


    To understand better, why do you need both signals ?

  • I need one signal from my custom delegate to detect that the cell in col 2 is not empty, then i will activate the next row witch is not editable

    another signal itemChanged(QtableWidgetItem *) to detect that the editig of same;

    when the first signal called, he makes the second signal working also

    witch is a problem .

    i have make a condition if ( item(row-1)->text().isEmpty) return ;
    and it works

    [quote author="SGaist" date="1381099460"]Hi,

    To understand better, why do you need both signals ?[/quote]

    sorry, the problem that i can't explain my problem !!

    thanks, i have got the solution

Log in to reply