The problem with your code is that you are not even checking where you are supposed to draw. The rect you get is not the whole scene rect but rather the rect that graphics view asks you to redraw. Regarding font scaling, if you manage to demonstrate the problem to us using code, maybe we can provide a fix. Currently the code you have does not take zooming into account, so the larger the zoom, the larger the text you'll get. As I said before, you'd have to invert the transform so that the original matrix is used or reimplement paintEvent and draw in widget coordinates:

Qt Code:
  1. class GV : public QGraphicsView {
  2. public:
  3. GV(QWidget *parent = 0) : QGraphicsView(parent) {}
  4. void setName(const QString &n) { m_name = n; update(); }
  5. protected:
  6. void paintEvent(QPaintEvent *pe) {
  7. QGraphicsView::paintEvent(pe);
  8. QPainter p(viewport());
  9. QFont f("Arial", 20);
  10. p.setFont(f);
  11. p.drawText(viewport()->rect(), Qt::AlignRight|Qt::AlignBottom, m_name);
  12. }
  13. private:
  14. QString m_name;
  15. };
To copy to clipboard, switch view to plain text mode