QDialog / QListView problem
hi,
i have a problem using a QDialog to hold a QListView. The dialog displays all files in a selected folder. So far, everything works fine, all files are selectable and have a correct status (selected/unselected). The Problem: Pressing control(strg) + a selects all the displayed files. I didn't implement that, so i assume either the QDialog or the QListView accepts this event. Unfortunately, the strg+a - selection selects all items but gives a wrong amout of contained items. if there are 35 items in a folder, strg+a select them all but sets there number to 140 (x4 everytime).
How can i disable the strg+a selection or overwrite it ? is there a solution without subclassing QDialog or QListView (hell of a work for me in both cases due to a huge project...) ?
:confused:
Code:
folderDialog->setWindowModality(Qt::ApplicationModal);
folderDialog->resize(800, 600);
folderDialog->setWindowTitle("Selected Folder");
folderModel
->setFilter
(QDir::Files);
folderView->setModel(folderModel);
folderDialogLayout->addWidget(folderView);
...
folderDialog->setLayout....
Re: QDialog / QListView problem
Yes, Ctrl+A is a shortcut implemented in the view. The problem seems to derive from the fact that a) QDirModel has 4 fixed colums, b) the shortcut makes everything in the model selected. So even if QListView shows only data from the first column of QDirModel, hidden columns count for QItemSelectionModel. One possible solution is to subclass QDirModel and reimplement columnCount():
Code:
{
public:
int columnCount
(const QModelIndex
& parent
= QModelIndex()) const {
return 1;
}
};