开发者

how to use QTable::editCell()

I don't understand how QTable::editCell() should be used. I am trying to do some error checking based on entries made by user in a QTable as mentioned in my another question.

I would like to give user an opportunity to re-edit the cell which has error. For example, if name column entry has some special characters such as '(', the user should be prompted for the error and the control should go back to same cell in edit mode. I tried using QTable::editCell() in my code as shown below.

Table->editCell(row, 0, TRUE);
name = Table->text(row, 0);

However, this doesn't work as expected. The control doesn't stay in the cell at all and obviously the name i开发者_如何学Gos not correctly collected. So, my question is how to ensure from within code that a cell of QTable can be edited so that the edited contents can be accessed immediately in next statement (as shown in above code).

Note: I am working with qt 3.3.8 only.


I don't think you can do that. You'll have to go back to the event loop, and wait for one of the signals (like valueChanged(row,col)) to be fired to re-validate the data.

A blocking wait on a GUI object is often not a good approach (except for modal dialogs).


I know I'm a little late here but you should use the following connect statement with your own custom function to do your specific needs such as below. You can also use this method to disable users from entering in special characters within you custom function. That way they wont ever have to correct undesirable characters.

connect(ui->tableWidget, SIGNAL(cellChanged(int,int)), this, SLOT(customFunction(int,int)));

void updateTable
{
    //remove invalid characters
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜