Results 1 to 5 of 5

Thread: Adding CheckBoxes In ListView in Qt-4

  1. #1
    Join Date
    May 2011
    Location
    Mumbai, India
    Posts
    22
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Adding CheckBoxes In ListView in Qt-4

    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::CheckBo x );
    }

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Adding CheckBoxes In ListView in Qt-4

    Again, please use the [CODE] tags.
    You may want to read documentation for QListWidgetItem and QListWidget.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Adding CheckBoxes In ListView in Qt-4

    Have a look at this post, you may need to change QPushButton to QCheckBox

    http://www.qtcentre.org/threads/4146...ht=#post190790

  4. #4
    Join Date
    Sep 2014
    Posts
    8
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Adding CheckBoxes In ListView in Qt-4

    Hi Ketan,
    I am wanting to add a check box in column 0 in a ListView and I need to use Qt3.
    Is the code snippet above for Qt3?
    I am a complete newbie with Qt (any version) and would be so grateful for any information you can give me.
    Many thanks,
    Gary

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding CheckBoxes In ListView in Qt-4

    It is almost for Qt3.
    In Qt3 the class was calles QCheckListItem (without the "3", this was added to mark it as a compatibility class in Qt4)

    Cheers,
    _

Similar Threads

  1. to show Checkboxes in listview
    By Ketan Shah in forum Newbie
    Replies: 3
    Last Post: 23rd May 2011, 09:01
  2. QFileSystemModel with checkboxes...
    By been_1990 in forum Qt Programming
    Replies: 14
    Last Post: 11th March 2011, 15:01
  3. Replies: 8
    Last Post: 23rd October 2009, 15:33
  4. qtreeview + checkboxes
    By lamera in forum Newbie
    Replies: 9
    Last Post: 6th September 2008, 22:10
  5. checkboxes
    By abrou in forum Newbie
    Replies: 2
    Last Post: 1st February 2008, 18:52

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.