yagabey
1st August 2016, 12:25
Hi,
I have QGraphicsObject derived items on a QGraphicsScene. Before Qt 5.7 everything was good. But when i compile project with 5.7 , painting of objects are getting out of view as seen on the attached image:
12052
The main widget is split into 2 with a splitter. Left side is my view containing GraphicsObjects and right side is a tableview. As you could see, graphics objects overlaps table view and messes up all painting.
i am just overriding paint method like that:
void RealTimeChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
//painter->drawImage(boundingRect(),m_image.toImage());
int width = m_rootData->w;
int height= m_rootData->h;
QRectF mrect= boundingRect().adjusted(width/15,height/10,-width/15,-height/10);
painter->fillRect(boundingRect(),QColor(Qt::white));
painter->fillRect(boundingRect().adjusted(3,3,-3,-3),QColor(m_chrtdata->bgColor));
const QPointF points[7] = {
QPointF(width/8, height/1.3),
QPointF(width/4, height/2) ,
QPointF(3*width/8, height/1.8),
QPointF(width/2, height/2.5),
QPointF(5*width/8, height/2.2) ,
QPointF(3*width/4, height/4),
QPointF(7*width/8, height/3)
};
painter->setPen(QPen(Qt::red));
painter->drawPolyline(points, 7);
painter->setPen(QColor(m_chrtdata->txtColor));
painter->drawLine(mrect.bottomLeft(),mrect.bottomRight());
painter->drawLine(mrect.bottomLeft(),mrect.topLeft());
painter->setPen(QPen(QColor(m_chrtdata->txtColor), 1, Qt::DotLine));
painter->drawRect(mrect);
painter->drawRect(QRectF(mrect.topLeft() ,
QPointF(mrect.bottomLeft().x()+mrect.width()/2,
mrect.bottomRight().y()) ));
painter->drawRect(QRectF(QPointF(mrect.topLeft().x(),
mrect.topLeft().y()+mrect.height()/2) ,
mrect.bottomRight() ));
}
Any idea what changed on qt 5.7 and how to fix this ?
Regards,
Yigit
I have QGraphicsObject derived items on a QGraphicsScene. Before Qt 5.7 everything was good. But when i compile project with 5.7 , painting of objects are getting out of view as seen on the attached image:
12052
The main widget is split into 2 with a splitter. Left side is my view containing GraphicsObjects and right side is a tableview. As you could see, graphics objects overlaps table view and messes up all painting.
i am just overriding paint method like that:
void RealTimeChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
//painter->drawImage(boundingRect(),m_image.toImage());
int width = m_rootData->w;
int height= m_rootData->h;
QRectF mrect= boundingRect().adjusted(width/15,height/10,-width/15,-height/10);
painter->fillRect(boundingRect(),QColor(Qt::white));
painter->fillRect(boundingRect().adjusted(3,3,-3,-3),QColor(m_chrtdata->bgColor));
const QPointF points[7] = {
QPointF(width/8, height/1.3),
QPointF(width/4, height/2) ,
QPointF(3*width/8, height/1.8),
QPointF(width/2, height/2.5),
QPointF(5*width/8, height/2.2) ,
QPointF(3*width/4, height/4),
QPointF(7*width/8, height/3)
};
painter->setPen(QPen(Qt::red));
painter->drawPolyline(points, 7);
painter->setPen(QColor(m_chrtdata->txtColor));
painter->drawLine(mrect.bottomLeft(),mrect.bottomRight());
painter->drawLine(mrect.bottomLeft(),mrect.topLeft());
painter->setPen(QPen(QColor(m_chrtdata->txtColor), 1, Qt::DotLine));
painter->drawRect(mrect);
painter->drawRect(QRectF(mrect.topLeft() ,
QPointF(mrect.bottomLeft().x()+mrect.width()/2,
mrect.bottomRight().y()) ));
painter->drawRect(QRectF(QPointF(mrect.topLeft().x(),
mrect.topLeft().y()+mrect.height()/2) ,
mrect.bottomRight() ));
}
Any idea what changed on qt 5.7 and how to fix this ?
Regards,
Yigit