Results 1 to 2 of 2

Thread: QDialog / QListView problem

  1. #1
    Join Date
    May 2007
    Posts
    33
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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...) ?


    Qt Code:
    1. folderDialog = new QDialog;
    2. folderDialog->setWindowModality(Qt::ApplicationModal);
    3. folderDialog->resize(800, 600);
    4. folderDialog->setWindowTitle("Selected Folder");
    5. folderDialogLayout = new QVBoxLayout;
    6.  
    7. folderModel = new QDirModel;
    8. folderModel->setFilter(QDir::Files);
    9. folderView = new QListView();
    10. folderView->setModel(folderModel);
    11. folderView->setSelectionMode(QAbstractItemView::MultiSelection);
    12. folderDialogLayout->addWidget(folderView);
    13. ...
    14. folderDialog->setLayout....
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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():
    Qt Code:
    1. class DirModel : public QDirModel
    2. {
    3. public:
    4. DirModel(QObject* parent = 0)
    5. : QDirModel(parent) { }
    6.  
    7. int columnCount(const QModelIndex& parent = QModelIndex()) const
    8. {
    9. return 1;
    10. }
    11. };
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 04:13
  2. Problem with doubleClicked in QListView with Qt 4.2.2
    By gauravagarwal in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2007, 11:28
  3. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 09:16
  4. Problem with drag&drop in qlistview
    By mambo in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2006, 17:14
  5. QListView & backgroundBrush -> Houston we hv a problem
    By travis in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2006, 08:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.