Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding CheckBoxes In ListView in Qt-4
Forum Updated to NodeBB v4.3 + New Features

Adding CheckBoxes In ListView in Qt-4

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 8.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Ketan Shah
    wrote on last edited by
    #1

    hii,this is my code...I want to display all the .dll files present in a directory as checkable items in a list....how can i do this....can any 1 help me for this...
    i had already done this using Q3CheckListItem....but now i want to use any new method that exist in Qt4...and dont want to use the Qt3 Support...

    @
    QStringList fileTypes;
    QDir dir;
    QFileInfo fileInfo;
    QStringList files;
    Q3CheckListItem *item;

    listView->setResizeMode( Q3ListView::LastColumn );
    listView->addColumn( "Extension" );
    //view.show();
    //ui->listView->header()->hide();

    fileTypes << "_*.dll" ;
    dir.setPath("E:/qtpro/ext");
    dir.setNameFilters(fileTypes);
    files = dir.entryList();

    for (int i = 0; i < files.size(); ++i)
    {
    fileInfo = files.at(i);
    item = new Q3CheckListItem(listView,QString("%1").arg(fileInfo.fileName()),Q3CheckListItem::CheckBox );
    }
    @

    EDIT: please use @-tags for code segments, Gerolf

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Have a look at :

      http://developer.qt.nokia.com/wiki/QSortFilterProxyModel_subclass_to_add_a_checkbox

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Feel free to ask any questions on the use of the code referenced above, or make suggestions for improvements. I am the author of that code, so I am interested in your feedback.

        Note that QFileSystemModel is capable of filtering, so filtering based on the extension is trivial.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cyberandy
          wrote on last edited by
          #4

          The Qt4 QListView is a one dimensional MVC-Container. Therefore you need a model, which reacts on the role Qt::CheckStateRole in its data method.

          Andreas Metzner
          Dipl.-Inform. Univ.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved