Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, January 2007
About QTableWidget and QTableWidgetItem


Message 1 in thread

I use QT 4.14

I wrote a spreadsheet application. The following is a example:

The original spreadsheet:
-----------------------------------------------------------
|   1   |   2   |   3   |   4   |   5   |   6   |   7   |
-----------------------------------------------------------

The user click the cell 3, and i use the
    connect(this, SIGNAL(cellDoubleClicked(int, int)),
            this, SLOT(getCellPosition(int, int)));
    connect(this, SIGNAL(cellClicked(int, int)),
            this, SLOT(getCellPosition(int, int)));
to get the clicked cell's position

then, user modify the cell 3's value to 1, as
 ----------------------------------------------------------- |   1   |   2
|   1   |   4   |   5   |   6   |   7   |
-----------------------------------------------------------

and i use the
    connect(this, SIGNAL(itemChanged(QTableWidgetItem *)),
                 this, SLOT(documentWasModified(QTableWidgetItem *)));
to get the new cell value

Now the problem is: if the user modified the cell, he has to click other
cell to make the cell's new value entered,
which emit a signal SIGNAL(cellClicked(int, int))  And this signal would
race with the SIGNAL(itemChanged(QTableWidgetItem *))
So sometime the cellClick singal may be earlier, and if i want to keep the
modified cell's position use getCellPosition(int, int)
i will get the wrong position.

Is there any method to get the item's position in table using the
QTableWidgetItem? Or Enter the new value of table item without have
to click another item? Or manage the sequence of singals?

Thanks!