Hi to all,
I'm trying to build a rectangle (QGraphicsRectItem) with a text inside (QGraphicsTextItem) perfectly centered both vetically and horizontally as child, if it's the best solution. I've tried the following code:
for (int i = 0; i < 12; i++)
{
month
->setPen
(QPen(Qt
::red,
1, Qt
::SolidLine));
month->setBrush(Qt::NoBrush);
}
for (int i = 0; i < 12; i++)
{
QGraphicsRectItem *month =
new QGraphicsRectItem(QRect(margineX + 60 * i, endY - margineY + 2, 60, 30), 0, scene);
month->setPen(QPen(Qt::red, 1, Qt::SolidLine));
month->setBrush(Qt::NoBrush);
QGraphicsTextItem *textMonth =
new QGraphicsTextItem(QString("%1").arg(i + 1), month);
}
To copy to clipboard, switch view to plain text mode
and...it doesn't work. Thanks in advance!
Bookmarks