QTCreator Giving ListWidgetItems Multiple Attributes

38 views Asked by At

So I'm using QTCreator to create a GUI for a project. I'm reading items from a file, and then those items are imported into a ListWidget with checkboxes next to each item. I was wondering if it's possible to have the checkbox along with a spin box or some other sort of numeric attribute tied to each item, and if so could you explain how? Edit: If anyone know hows to add any of the editable text boxes instead that'd actually work even better. This is what I'm currently doing to open/read the file:

QFile ingFile("/root/Desktop/file.txt");
ingFile.open(QIODevice::ReadOnly);
QTextStream in(&ingFile);
QStringList inglist;
QString line = in.readLine();
while(!line.isNull()){
    inglist.append(line);
    line = in.readLine();
}
QStringListIterator it(inglist);
while(it.hasNext()){
    QListWidgetItem *listitem = new QListWidgetItem(it.next());
    listitem->setCheckState(Qt::Unchecked);
    ui->ingList->addItem(listitem);
}

Thanks!

0

There are 0 answers