How to save the state of Q3Checklistitem on being checked or unchecked..



  • 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::CheckBox );
    }
    @

    Edit: please use @ tags around code blocks to format them; Andre
    Edit: merged two related threads; ZapB



  • If this is new code: please don't use the Qt3 helper classes. They will not be part of Qt5. Use the new model-view classes instead.

    If you want to be informed on the state change of an item, you could subclass Q3CheckListItem and re-implement the stateChange method. You can read all the properties of the item you want there, and use that information in whatever way you want.

    For instance, you could consider making your Q3CheckListItem subclass inherit from both QObject and Q3CheckListItem, and give the item a signal that it was clicked.



  • How can i save the state of checkbox when checked or unchecked...
    below is my code...can any1 help...
    @
    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 );
    }
    @



  • You could store the checkboxes and their states in a QMap. If needed, you could convert the map into a file format using QDataStream, see the "documentation":http://doc.qt.nokia.com/4.7/qmap.html#operator-lt-lt-82



  • Please use @ tags as Andre recommended you in another post.

    BTW, why do use Q3* classes? Maybe you can avoid them and use ones that are not obsolete?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.