Thanks! That explains the loop from hell: setScene() and show() were causing paintEvents in the paintEvent.
But I still do not understand how to get the QPixmap into the QGraphicsView.
I moved QGraphicsView and QGraphicsScene out of the paintEvent so that they only get called once.
I moved QPixmap so it is available to the class.
I got rid of the view->show() since I do not think it is needed.
But I still do not see the image in the QGraphicsView.
Am I getting closer at least?
ViewerDialog
::ViewerDialog(QWidget *parent
) : ui(new Ui::ViewerDialog)
{
ui->setupUi(this);
...
pixmap = new QPixmap(ui
->view
->size
());
}
...
void ViewerDialog::updateUi()
{
...
scene->setSceneRect(ui->view->rect());
ui->view->setScene(scene);
scene->addPixmap(*pixmap);
}
...
{
vector<SyDataT>::iterator it;
for (it = sy->syVector.begin(); it < sy->syVector.end(); it++)
{
if ((pl == it->pl) && (fr == it->fr))
{
...
QColor color
(red, green, blue, alpha
);
painter.setPen(color);
painter.drawPoint(it->az, it->el);
}
}
}
ViewerDialog::ViewerDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ViewerDialog)
{
ui->setupUi(this);
...
pixmap = new QPixmap(ui->view->size());
scene = new QGraphicsScene(ui->view);
}
...
void ViewerDialog::updateUi()
{
...
scene->setSceneRect(ui->view->rect());
ui->view->setScene(scene);
scene->addPixmap(*pixmap);
}
...
void ViewerDialog::paintEvent(QPaintEvent *e)
{
QPainter painter(pixmap);
vector<SyDataT>::iterator it;
for (it = sy->syVector.begin(); it < sy->syVector.end(); it++)
{
if ((pl == it->pl) && (fr == it->fr))
{
...
QColor color(red, green, blue, alpha);
painter.setPen(color);
painter.drawPoint(it->az, it->el);
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks