hey all,
i have application with QTableWidget of 3X4. i need to load image along with corresponding name of the icon.
i have the following code to display text
fnt.setPointSize(30);
fnt.setFamily("Arial");
for (int r = 0; r < t.rowCount(); ++r)
{
for (int c = 0; c < t.columnCount(); ++c)
{
item->setBackgroundColor(Qt::black);
item
->setIcon
(QIcon(QString(":/images/img%1.png").
arg(r
* t.
columnCount() + c
)));
item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
// writting icon name
item->setTextColor(Qt::white);
item->setFont(fnt);
item->setText("help");
item->setTextAlignment(Qt::AlignBottom|Qt::AlignLeading);
t.setItem(r, c, item);
}
}
QFont fnt;
fnt.setPointSize(30);
fnt.setFamily("Arial");
for (int r = 0; r < t.rowCount(); ++r)
{
for (int c = 0; c < t.columnCount(); ++c)
{
QTableWidgetItem* item = new QTableWidgetItem;
item->setBackgroundColor(Qt::black);
item->setIcon(QIcon(QString(":/images/img%1.png").arg(r * t.columnCount() + c)));
item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
// writting icon name
item->setTextColor(Qt::white);
item->setFont(fnt);
item->setText("help");
item->setTextAlignment(Qt::AlignBottom|Qt::AlignLeading);
t.setItem(r, c, item);
}
}
To copy to clipboard, switch view to plain text mode
following code displays help in all the cell. now my question is how would i display different text in each cell based on icon i load.
hope i am clear.
Bookmarks