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:
{
QPen temppen
=brushes
::textpen;
painter->setPen(temppen);
QFont tempfont
=fonts
::standardfont;
painter->setFont(tempfont);
painter->drawText(boundingRect(),Qt::AlignCenter,getUiname());
}
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());
}
To copy to clipboard, switch view to plain text mode
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");
painter->drawText(boundingRect(),Qt::AlignCenter,"Test");
To copy to clipboard, switch view to plain text mode
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;
}
QString uimodule::getUiname() const
{
return uiname;
}
To copy to clipboard, switch view to plain text mode
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?
Bookmarks