#include <QtGui>
{
protected:
{
opt.decorationAlignment = Qt::AlignCenter;
return opt;
}
};
int main(int argc, char* argv[])
{
TableWidget t;
t.setRowCount(4);
t.setColumnCount(4);
for (int r = 0; r < t.rowCount(); ++r)
{
for (int c = 0; c < t.columnCount(); ++c)
{
item
->setIcon
(QIcon(":/trolltech/styles/commonstyle/images/left-128.png"));
t.setItem(r, c, item);
}
}
t.show();
return a.exec();
}
#include <QtGui>
class TableWidget : public QTableWidget
{
protected:
QStyleOptionViewItem viewOptions() const
{
QStyleOptionViewItem opt = QTableWidget::viewOptions();
opt.decorationPosition = QStyleOptionViewItem::Bottom;
opt.decorationAlignment = Qt::AlignCenter;
return opt;
}
};
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
TableWidget t;
t.setRowCount(4);
t.setColumnCount(4);
for (int r = 0; r < t.rowCount(); ++r)
{
for (int c = 0; c < t.columnCount(); ++c)
{
QTableWidgetItem* item = new QTableWidgetItem;
item->setIcon(QIcon(":/trolltech/styles/commonstyle/images/left-128.png"));
t.setItem(r, c, item);
}
}
t.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks