Qt-interest Archive, April 2007
font in tablewidgetitem
Message 1 in thread
Hi,
i have this code
item->setFont(font);
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsEditable);
but when i write in the item i look standard font (very small to my
application) and only after that i have clicked up other item i see correct
font (and dimension). I should correct font also while i write. is it
possible?
Thanks
Nicola
--
[ signature omitted ]
Message 2 in thread
> i have this code
>
> item->setFont(font);
>
> item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsEditable);
>
> but when i write in the item i look standard font (very small to my
> application) and only after that i have clicked up other item i see correct
> font (and dimension). I should correct font also while i write. is it
> possible?
Hi
Yes, it is possible with a custom delegate. Reimplement
QItemDelegate::setEditorData() to apply the font:
void MyItemDelegate::setEditorData(QWidget* editor, const QModelIndex&
index) const
{
QItemDelegate::setEditorData(editor, index);
QFont font = qvariant_cast<QFont>(index.data(Qt::FontRole));
editor->setFont(font);
}
--
[ signature omitted ]