mlik
13th May 2010, 08:41
Hi
I am having problems displaying a text string in the top left hand corner of my QGraphicsView widget. When scrolling the text scrolls as well, I would like the text to stay in position at the top left hand corner of the widget.
UpdateDisplay is called when an image is ready for display, this forces the paint event for the QGraphicsView
My code is below, what am I doing wrong?
void CScanWin::paintEvent(QPaintEvent *event)
{
QGraphicsView::paintEvent(event); //pass the event to the graphic view ???
QString status = "All Sources available..." + QString::number(q);
QPainter painter(viewport());
painter.setPen(QColor(Qt::yellow));
painter.drawText(10, 10, status);
}
o
void CScanWin::UpdateDisplay()
{
q++;
cscanScene->clear();
cscanScene->setSceneRect(img->rect());
cscanScene->addPixmap(QPixmap::fromImage(*img));
viewport()->update();
}
Thanks
I am having problems displaying a text string in the top left hand corner of my QGraphicsView widget. When scrolling the text scrolls as well, I would like the text to stay in position at the top left hand corner of the widget.
UpdateDisplay is called when an image is ready for display, this forces the paint event for the QGraphicsView
My code is below, what am I doing wrong?
void CScanWin::paintEvent(QPaintEvent *event)
{
QGraphicsView::paintEvent(event); //pass the event to the graphic view ???
QString status = "All Sources available..." + QString::number(q);
QPainter painter(viewport());
painter.setPen(QColor(Qt::yellow));
painter.drawText(10, 10, status);
}
o
void CScanWin::UpdateDisplay()
{
q++;
cscanScene->clear();
cscanScene->setSceneRect(img->rect());
cscanScene->addPixmap(QPixmap::fromImage(*img));
viewport()->update();
}
Thanks