Results 1 to 2 of 2

Thread: Get The Q3CheckListItem name on checking the item

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

    Default Get The Q3CheckListItem name on checking the item

    hii,
    I want to get the respective name of the Q3CheckListItem on checking the respective item…
    how can i do this plz help..Below is my code…

    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 );
    }
    Last edited by Ketan Shah; 24th May 2011 at 10:29.

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

    Default Re: Get The Q3CheckListItem name on checking the item

    Q3 classes are not recommend to be used for new code, it's only to support old code

    There are couple of ways to do this, one of the ways would be implement a class which is a sub-class of Q3CheckListItem and use that new class to add items on the view. Then implement Q3CheckListItem::stateChange() virtual method in the new class, and use the text() method to get the name an use it.

    Example:
    Qt Code:
    1. class myItem : public Q3CheckListItem
    2. {
    3. public:
    4. //add required constructors
    5. protected:
    6. stateChange (bool b)
    7. {
    8. QString item_name;
    9. if(b == true)
    10. {
    11. if(state() == Q3CheckListItem::On)
    12. {
    13. item_name = text();
    14. // Use item_name or whatever you want
    15. }
    16. }
    17. }
    18. };
    19.  
    20. ...
    21. for (int i = 0; i < files.size(); ++i)
    22. {
    23. fileInfo = files.at(i);
    24. item = new myItem(listView,QString(”%1”).arg(fil eInfo.fileName()),Q3CheckListItem::CheckBox );
    25. }
    26. ...
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Q3Checklistitem stateChange function not working
    By Ketan Shah in forum Newbie
    Replies: 3
    Last Post: 23rd May 2011, 08:38
  2. Checking QByteArray
    By camol in forum Qt Programming
    Replies: 3
    Last Post: 18th March 2011, 13:07
  3. Checking for gui events
    By mgb in forum Qt Programming
    Replies: 8
    Last Post: 8th February 2011, 22:07
  4. Checking if bad pointer?
    By steg90 in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2007, 09:06
  5. checking for null
    By drkbkr in forum General Programming
    Replies: 6
    Last Post: 13th March 2006, 21:54

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
  •  
Qt is a trademark of The Qt Company.