PDA

View Full Version : QGraphicsView



Maluko_Da_Tola
24th July 2010, 01:57
Hi

I am trying to display graphics in my a QGraphicsView object created in the main form using Qt designer. I am using the following function paintEvent in the mainwindow.cpp


void QGraphicsView::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(Qt::blue);
painter.setFont(QFont("Arial", 30));
painter.drawText(rect(), Qt::AlignCenter, "Qt");
}

Why do I still not get any drawings in my QGraphicsView object?

Thank you

Lykurg
24th July 2010, 05:40
Well the code looks fine. But are you aware that one normally uses as QGraphicsScene inside a graphics view? There you can add a QGraphicsTextItem.