PDA

View Full Version : Font size in QGraphicsTextItem



rippa
7th December 2008, 11:46
I add QGraphicsTextItem to graphics scene and then change its font family and font size. It works ok, but when I click and/or move my item font size changes to the 12 size. Actually its changed in QGraphicsTextItem::mouseReleaseEvent().
What is needed to force QGraphicsTextItem keep font size? Thanks in advance.

rippa
7th December 2008, 19:11
I found where fonts size changes but still cant understand why



void MyPlainTextItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent )
{
MyTW::self()->fillTable(props); //Filling property table for this item when clicked. If I delete this line all works fine.
cout << this << " is selected!" << endl;
QGraphicsTextItem::mouseReleaseEvent(mouseEvent);
}


This is fillTable function, it has nothing to do with QGrpahicsTextItem but still somehow it changes font size.


void MyTW::fillTable(QMap<QString,QString> map)
{
clear();
setRowCount(map.size());
QTableWidgetItem* twi = new QTableWidgetItem();
twi->setText(QString::fromLocal8Bit("оБЪЧБОЙЕ"));
setHorizontalHeaderItem(0,twi);
QTableWidgetItem* twi_1 = new QTableWidgetItem();
twi_1->setText(QString::fromLocal8Bit("ъОБЮЕОЙЕ"));
setHorizontalHeaderItem(1,twi_1);
QMapIterator<QString,QString> i(map);
int j =0;
while (i.hasNext())
{
i.next();
QTableWidgetItem* item = new QTableWidgetItem();
item->setText(i.key());
setItem(j,0,item);
QTableWidgetItem* item_1 = new QTableWidgetItem();
item_1->setText(i.value());
setItem(j,1,item_1);
j++;
}
}