Important: Please read the Qt Code of Conduct -

Stardelegate example - how to read data from my own widget item

  • Hello

    I am creating code based on this stardelegate example: . I designed my own similar widget but only with checked-unchecked icon. I need to read all table parameters after button click or sth like that. If I want to read widget item integer value I am using for ex:
    @val[i] = ui->tableIn->item(0 + i*3, 2)->text().toInt();@

    but unfortunatelly I have no idea how to read a number of stars from this example outside delegate. I was trying item(row, col)->data(0) etc but I don't know how to read this qVariant as integer or bool in my example.

    When I want to write to my widget element I am using this construct:
    @ui->tableIn->item(0 + i*3, 2)->setData(0, qVariantFromValue(IconPainter(booleanValue)));@
    there is in stardelegate example:
    @item3->setData(0, qVariantFromValue(StarRating(staticData[row].rating)));@

    Best reagrds,

  • Hello

    I found solution for my problem. That is for example:
    @val = IconPainter(qVariantValue<IconPainter>(ui->table->item(0 + i*3, 0)->data(0))).getState();@

    I hope that's optimal solution :)

Log in to reply