but how to obtain a text centered both vetically and horizontally in the rectangle?
thats what i am suggesting .. combine both the text and rectangle into single QGraphicsItem ..

paint such that
create a custom QGraphicsItem()
Qt Code:
  1. class CustomItem : public QGraphicsRectItem
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. CustomItem(const QRectF &rect);
  7. void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
  8. QRectF boundingRect();
  9.  
  10. };
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. CustomItem::CustomItem(const QRectF &rect)
  2. {
  3. textItem->setDefaultTextColor(QColor(255,255,255,255));
  4. textItem->setPos(x, y); //here u set position of text
  5. textItem->setPlainText(message); //set your text here
  6. }
  7.  
  8. void CustomItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o, QWidget *widget)
  9. {
  10. painter->setBrush(QBrush(QColor(21, 155, 210, 255)));
  11. painter->drawRect(rect());
  12.  
  13. }
To copy to clipboard, switch view to plain text mode 

now the item is ready in horizontal ... now in parent graphicsView() rotate it using previous code ...