Add square in table widget
-
wrote on 8 Jul 2018, 15:02 last edited by aha_1980 7 Aug 2018, 19:28
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 ??? );
-
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 ??? );
wrote on 8 Jul 2018, 15:12 last edited byYou generate QImage with setColor tranform with QPixmap::fromImage for instance.
-
You generate QImage with setColor tranform with QPixmap::fromImage for instance.
-
wrote on 8 Jul 2018, 16:07 last edited by
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);
1/4