Unsolved Add square in table widget
-
Hi guys,
I have a table widget with 3 rows and 5 columns and I wanna add in the first column of any row a simple green square.
I don t want add an external png, how I can do it?for (int j = 0; i < var.size(); ++j) ui->tableWidget->setItem(j, 0, new ??? );
-
You generate QImage with setColor tranform with QPixmap::fromImage for instance.
-
@koahnig
I don't understand how can i generate the square -
auto model = ui->tableWidget->model(); QPixmap greenSquare(20,20); greenSquare.fill(Qt::green); for(int i=0, maxRow = model ->rowCount();i<maxRow ;++i) model->setData(model->index(i,0),greenSquare,Qt::DecorationRole);