0backbone0
14th October 2015, 20:31
Hi,
I ran into a rather strange problem.
I have a custom QGraphics Item, that should just print a Text.
The Paint Function looks like this:
void text::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPen temppen=brushes::textpen;
painter->setPen(temppen);
QFont tempfont=fonts::standardfont;
painter->setFont(tempfont);
painter->drawText(boundingRect(),Qt::AlignCenter,getUiname( ));
}
But whenever this function is called the Text is shifted upwards, and are cut from the Top Border of the BoundingRect.
If I change the draw method to this:
painter->drawText(boundingRect(),Qt::AlignCenter,"Test");
The text is centered in the Bounding Rectangle as expected.
getUiname() is rather simple, I don't think that the problem is there.
QString uimodule::getUiname() const
{
return uiname;
}
The only thing left to mention is that getUiname is in the Baseclass of my GraphicsItem. But this should make no difference in my opinion.
Is this a bug? Any ideas what I could try to fix it?
I ran into a rather strange problem.
I have a custom QGraphics Item, that should just print a Text.
The Paint Function looks like this:
void text::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPen temppen=brushes::textpen;
painter->setPen(temppen);
QFont tempfont=fonts::standardfont;
painter->setFont(tempfont);
painter->drawText(boundingRect(),Qt::AlignCenter,getUiname( ));
}
But whenever this function is called the Text is shifted upwards, and are cut from the Top Border of the BoundingRect.
If I change the draw method to this:
painter->drawText(boundingRect(),Qt::AlignCenter,"Test");
The text is centered in the Bounding Rectangle as expected.
getUiname() is rather simple, I don't think that the problem is there.
QString uimodule::getUiname() const
{
return uiname;
}
The only thing left to mention is that getUiname is in the Baseclass of my GraphicsItem. But this should make no difference in my opinion.
Is this a bug? Any ideas what I could try to fix it?