Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Stardelegate example - how to read data from my own widget item
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nibbit
    wrote on 22 Nov 2012, 11:38 last edited by
    #1

    Hello

    I am creating code based on this stardelegate example: http://doc.qt.digia.com/qt/itemviews-stardelegate.html . 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,
    nibbit

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nibbit
      wrote on 26 Nov 2012, 14:02 last edited by
      #2

      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 :)

      1 Reply Last reply
      0

      1/2

      22 Nov 2012, 11:38

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved