Results 1 to 6 of 6

Thread: How to perform some action on checking and unchecking te checkbox.

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

    Default How to perform some action on checking and unchecking te checkbox.

    Hii, can any1 tell me what function is used to perform some action on checking or unchecking the checkbox in a listview..
    below is my code, it shows the checkboxes in the listview…plz help..

    Qt Code:
    1. QListView *view;
    2. QStandardItem *parentItem;
    3. QStandardItem *myitem;
    4.  
    5. fileTypes << “_*.dll” ;
    6. dir.setPath(“E:/qtpro/ext”);
    7. dir.setNameFilters(fileTypes);
    8. files = dir.entryList();
    9.  
    10. model = new QStandardItemModel(centralWidget);
    11. parentItem = model->invisibleRootItem();
    12. for (int i = 0; i < files.size(); ++i)
    13. {
    14. fileInfo = files.at(i);
    15. myitem = new QStandardItem();
    16. myitem->setText(QString(”%0”).arg(fileInfo.fileName()));
    17. model->setItem(i, myitem);
    18. myitem->setCheckable(true);
    19. }
    20. view = new QListView(centralWidget);
    21. view->setGeometry(10, 20, 256, 192);
    22. view->setModel(model);
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 27th May 2011 at 06:51. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to perform some action on checking and unchecking te checkbox.

    Checking/Unchecking the box makes the model emit the dataChanged() signal for the respective index.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: How to perform some action on checking and unchecking te checkbox.

    can you please give me a sample code, describing how I could do it..

  4. #4
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to perform some action on checking and unchecking te checkbox.

    I'd suggest to start with reading the documentation of QAbstractItemModel::dataChanged(...)

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to perform some action on checking and unchecking te checkbox.

    Quote Originally Posted by Ketan Shah View Post
    can you please give me a sample code, describing how I could do it..
    You connect the signal to a custom slot and in the slot do the stuff you want to do.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: How to perform some action on checking and unchecking te checkbox.

    Read up on signals & slots.

Similar Threads

  1. Replies: 4
    Last Post: 13th January 2011, 07:58
  2. QActionGroup allowing unchecking ?
    By divide in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2010, 14:16
  3. Perform a cyclic task in a QState
    By schall_l in forum Qt Programming
    Replies: 1
    Last Post: 16th April 2010, 23:18
  4. Replies: 12
    Last Post: 22nd March 2010, 08:59
  5. Unchecking QRadioButton
    By gruszczy in forum Qt Programming
    Replies: 3
    Last Post: 26th February 2008, 00:55

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.