Details
-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
4.3.1
-
None
Description
This example demonstrates a bug in QTable.*
The intention is that the table automatically expands on selection/currentChanged. E.g. if you select a cell in the last row another one should be added. This part works fine.
The strangeness starts when you drag the mouse back up. Somehow the cells stay selected. This is not the way selection works in the rest of the table.
To reproduce:
run app
click and drag a selection from top left corner to cell 3, 3
drag cursor to cell 2,2. Notice that cell 3, 3 2,3 and 3,2 gets unselected.
Now click and drag a selection from top left to bottom left, you'll notice that a row was added. Now drag the mouse back to 1.1 Notice that cells 2,1 3,1 4,1 etc stay selected.
#include <QtGui>
class Table : public QTableWidget
{
Q_OBJECT
public:
Table(QWidget *parent = 0)
: QTableWidget(5, 5, parent)
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
QTableWidget::currentChanged(current, previous);
if (current.row() == rowCount() - 1)
}
#if 0 // this seems to exhibit the same problems
public slots:
void onSelectionChanged()
{
foreach(const QModelIndex &ind, selectionModel()->selectedIndexes()) {
if (ind.row() == rowCount() - 1)
}
}
#endif
};
#include "main.moc"
int main(int argc, char **argv)
{
QApplication a(argc, argv);
Table table;
table.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}