Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.0
-
None
-
Fedora 32, Qt installed in home via online installer
Description
QTableWidget::selectedRanges() reports previous selection (or is empty at first click) when mouse clicking to select a cell. This does not happen when using keyboard arrows.
How to reproduce:
test.pro
QT = core gui widgets SOURCES = main.cpp
main.cpp
#include <QApplication> #include <QDebug> #include <QTableWidget> int main(int argc, char * argv[]) { QApplication app(argc, argv); QTableWidget table(2, 2); QObject::connect(&table, &QTableWidget::currentCellChanged, [&] (int, int, int, int) { auto const ranges = table.selectedRanges(); if (!ranges.isEmpty()) qInfo() << ranges[0].topRow() << ranges[0].leftColumn(); }); table.show(); return app.exec(); }
Start the program and click on a cell. Nothing is printed. Click on a another cell, the coordinates of the previously selected one are printed.
Restart the program, this time use arrow keys to select a cell, the right coordinates are instantly printed.