Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.4.0
-
None
Description
When using the keyboard to manipulate a multi-selection QAbstractItemView subclass (such as QListView or QTreeView), the normal way to select multiple non-contiguous items is to hold Ctrl while using the arrow keys to move the focus around and then hitting the space bar to select or deselect the item. However, when the view contains checkboxes (Qt::ItemIsUserCheckable) the space bar is used to check or uncheck items. This would be fine, except that this behavior appears to completely mask the ability to add or remove the item from the current selection using the keyboard.
This can be seen with the following example:
#include <QtGui>
int main(int argc, char** argv)
{
QApplication a(argc,argv);
//Table Widget section
QTableWidget *tbw = new QTableWidget(3,2);
tbw->setHorizontalHeaderLabels (QStringList() << ("Header1") << ("Header2"));
QTableWidgetItem *myTwItem01 = new QTableWidgetItem;
myTwItem01->setText("item 1");
myTwItem01->setCheckState ( Qt::PartiallyChecked );
QTableWidgetItem *myTwItem02 = new QTableWidgetItem;
myTwItem02->setText("item 2");
myTwItem02->setCheckState ( Qt::Checked );
QTableWidgetItem *myTwItem03 = new QTableWidgetItem;
myTwItem03->setText("item 3");
myTwItem03->setCheckState ( Qt::Unchecked );
QTableWidgetItem *myTwItem04 = new QTableWidgetItem;
myTwItem04->setText("item 4");
myTwItem04->setCheckState ( Qt::PartiallyChecked );
QTableWidgetItem *myTwItem05 = new QTableWidgetItem;
myTwItem05->setText("item 5");
myTwItem05->setCheckState ( Qt::Unchecked );
QTableWidgetItem *myTwItem06 = new QTableWidgetItem();
myTwItem06->setText("item 6");
myTwItem06->setCheckState ( Qt::Checked );
tbw->setItem ( 0, 0, myTwItem01 );
tbw->setItem ( 1, 0, myTwItem02 );
tbw->setItem ( 2, 0, myTwItem03 );
tbw->setItem ( 0, 1, myTwItem04 );
tbw->setItem ( 1, 1, myTwItem05 );
tbw->setItem ( 2, 1, myTwItem06 );
//layout section
QVBoxLayout *layout = new QVBoxLayout;
tbw->setSelectionMode( QAbstractItemView::ExtendedSelection );
layout->addWidget(tbw);
QWidget myMain;
myMain.setLayout(layout);
myMain.show();
return a.exec();
}