thanks to all for u r suggestions
i am trying all of the above methods one by one.
unfortunately i got stuck in the first try .
here is the code
void bpg_graphicsview :: bpg_plot()
{
for (int i=0; i<LOOP; i++)
for (int j=0; j<COL; j++)
{
x[0]= i * cos(j*DEGREE_TO_RADIAN);
y[0]= i * sin(j*DEGREE_TO_RADIAN);
x[1]= (i +1)* cos(j*DEGREE_TO_RADIAN);
y[1]= (i +1)* sin(j*DEGREE_TO_RADIAN);
x[2] =(i +1)* cos((j+1)*DEGREE_TO_RADIAN);
y[2] =(i +1)* sin((j+1)*DEGREE_TO_RADIAN);
x[3] = (i)* cos((j+1)*DEGREE_TO_RADIAN);
y[3] = (i)* sin((j+1)*DEGREE_TO_RADIAN);
points
[0] = QPointF(x
[0], y
[0])+=QPointF(this
->width
()/2, this
->height
()/2);
points
[1] = QPointF(x
[1], y
[1])+=QPointF(this
->width
()/2, this
->height
()/2);
points
[2] = QPointF(x
[2], y
[2])+=QPointF(this
->width
()/2, this
->height
()/2);
points
[3] = QPointF(x
[3], y
[3])+=QPointF(this
->width
()/2, this
->height
()/2);
qDebug()<<i<<" "<<j;
this->update();
}
qDebug()<<"end";
}
void bpg_graphicsview
:: paintEvent(QPaintEvent * event
) {
qDebug()<<"paint Event";
painter.setBrush(Qt::red);
painter.drawPolygon(points, 4);
}
void bpg_graphicsview :: bpg_plot()
{
for (int i=0; i<LOOP; i++)
for (int j=0; j<COL; j++)
{
x[0]= i * cos(j*DEGREE_TO_RADIAN);
y[0]= i * sin(j*DEGREE_TO_RADIAN);
x[1]= (i +1)* cos(j*DEGREE_TO_RADIAN);
y[1]= (i +1)* sin(j*DEGREE_TO_RADIAN);
x[2] =(i +1)* cos((j+1)*DEGREE_TO_RADIAN);
y[2] =(i +1)* sin((j+1)*DEGREE_TO_RADIAN);
x[3] = (i)* cos((j+1)*DEGREE_TO_RADIAN);
y[3] = (i)* sin((j+1)*DEGREE_TO_RADIAN);
points[0] = QPointF(x[0], y[0])+=QPointF(this->width()/2, this->height()/2);
points[1] = QPointF(x[1], y[1])+=QPointF(this->width()/2, this->height()/2);
points[2] = QPointF(x[2], y[2])+=QPointF(this->width()/2, this->height()/2);
points[3] = QPointF(x[3], y[3])+=QPointF(this->width()/2, this->height()/2);
qDebug()<<i<<" "<<j;
this->update();
}
qDebug()<<"end";
}
void bpg_graphicsview :: paintEvent(QPaintEvent * event)
{
qDebug()<<"paint Event";
QPainter painter(this);
painter.setBrush(Qt::red);
painter.drawPolygon(points, 4);
}
To copy to clipboard, switch view to plain text mode
this code works only when the contents of bpg_plot() are inside the paintEvent function
otherwise it never executes.
.
also,whenever update() is called the paintEvent does not work(qDebug()<<"paint Event"; does not print for every call).
please point where is the bug in the code .
Bookmarks