Quote Originally Posted by Lykurg View Post
Instead of setting the transformation to each item you use and in your particular case, it's better to create your own item and draw the text yourself:
In paint also draw the text via QPainter::drawText() (there are alignment flags) and then rotate the painter by 90°. And don't forget to implement the sizeHint() function.
QPainter will be the best solution when the rect area is smallest than the text, but if I try to create a QPainter object for that QGraphicsScene as the following code:
Qt Code:
  1. new QGraphicsScene(QRect(0, 0, endX, endY), this);
  2.  
  3. for (int i = 0; i < 12; i++)
  4. {
  5. new QGraphicsRectItem(QRect(margineX + 2 + 60 * i, endY - margineY + 2, 60, 30), 0, scene);
  6. // mese->setPen(QPen(Qt::red, 1, Qt::SolidLine));
  7. mese->setPen(Qt::NoPen);
  8. mese->setBrush(Qt::NoBrush);
  9.  
  10.  
  11. QPainter painter(scene);
  12. painter.drawText(mese, Qt::AlignCenter, mesiAnno.at(i));
  13. painter.drawRect(mese);
To copy to clipboard, switch view to plain text mode 

the compiler is not agree with me because:

Qt Code:
  1. error: no matching function for call to `QPainter::QPainter(QGraphicsScene*&)'
  2. note: candidates are: QPainter::QPainter(const QPainter&)
  3. note: QPainter::QPainter(QPaintDevice*)
To copy to clipboard, switch view to plain text mode 

where do i have to link my QPainter object???

thanks guys, I really appreciate your comments!