Ok I've done more research into this and I can actually elaborate on the issue now.
We have a child of a QGraphicsTextItem called Annotation. Annotation has a child of a QGraphicsLineItem called Line as a private attribute.
We can add the Annotation to the QGraphicsScene without a problem, both the Annotation and the Line both appear without any graphical errors when viewed on the QGraphicsView.
The problem comes when the QGraphicsView is rendered to a printer on Windows. While both the Annotation and the Line appear the entire area of the scene appears black EXCEPT for (what appears to be) the boundingRect of the Line.
I've examined the overloaded paint function of both Annotation and Line. It seems to be pretty straight forward, the printer's pen is set up and the line is drawn.
qreal lwidth = 1/(1000*option->levelOfDetail)*width; // required to multiple by 1000 to set correctly for the scene
myPen.setWidth((int)lwidth);
painter->setPen( myPen );
setLine( get_line(widget,line()) );
painter->drawLine( line() );
qreal lwidth = 1/(1000*option->levelOfDetail)*width; // required to multiple by 1000 to set correctly for the scene
QPen myPen = pen();
myPen.setWidth((int)lwidth);
painter->setPen( myPen );
setLine( get_line(widget,line()) );
painter->drawLine( line() );
To copy to clipboard, switch view to plain text mode
I also found that if I were to call QGraphicLineItem:
aint() within the overloaded function the Graphics View is printed without all the black, but there is a black line going around one edge of the boundingRect of the line.
I am sure that the problem is the Line because if I remove the code to add the Line no problems occur and the same problem does not occur with any of the other QGraphicsItems being added to the scene.
I hope I've been more through then I was with my past few posts.
Bookmarks