Details
-
Bug
-
Resolution: Cannot Reproduce
-
P3: Somewhat important
-
4.3.3
-
None
Description
Consider code below. How selection behaves is rather surprising. When using the keyboard, the selection is cumulative, but the mouse deselects and marks only one cell. Also, calling setCurrentCell() (see keyPressEvent() in code below) discards the current selection.
-------------------------------------------------------------------------------------------------------------------------
#include <QtGui/QApplication>
#include <QtGui/QTableWidget>
#include <QtDebug>
class MyTable : public QTableWidget
{
Q_OBJECT
public:
MyTable(int numRows, int numCols) : QTableWidget(numRows, numCols)
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &, const QEvent *ev = 0) const
{ Q_UNUSED(ev); return QItemSelectionModel::SelectCurrent; }void keyPressEvent(QKeyEvent *event)
{ QTableWidget::keyPressEvent(event); static int counter = 0; if (++counter == 10) setCurrentCell(rowCount() - 1, columnCount() - 1); qDebug() << counter << ". key pressed" << endl; }};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
MyTable table(8, 3);
table.resize(500, 500);
table.show();
return app.exec();
}
#include "main.moc"
-------------------------------------------------------------------------------------------------------------------------