tags:

views:

115

answers:

1

i want to set my font as bold in particular row column position of my tablewidget. I did like this but getting break.

QFont font("Helvetica", 12, QFont::Bold);
overviewTable->item(2,2)->setFont(font);

Please Help

A: 

Hi.

I think everything is ok. Here what docs said:

void QTableWidgetItem::setFont ( const QFont & font )

Sets the font used to display the item's text to the given font.

Maybe your overviewTable const?

ADDED:

This variant works fine for my Qt 4.6:

tableWidget = new QTableWidget(12, 3, this);

for (int i = 0; i < 12; i++) {
    for (int j = 0; j < 3; j++) {
        QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
            (i+1)*(j+1)));
        tableWidget->setItem(i, j, newItem);
    }
}

QFont font;
font.setBold(true);

tableWidget->item(2, 2)->setFont(font);
mosg