[Qt-interest] QGraphicsView + OpenGL + drawing foreground content with opacity

John Clayton johnclayton72 at gmail.com
Tue Sep 1 23:29:50 CEST 2009


Hi All,

Is there anything special I must do in either the QGraphicsView or its  
associated QGLWidget to enable drawing in the  
QGraphicsView::drawForeground() method using opacity?

I've got this code:
void PreviewView::drawForeground(QPainter * painter, const QRectF &  
rect) {
	QGraphicsView::drawForeground(painter, rect);
	
	QPainterPath path;
	// ... snipped code to build 'path'
	
	// now flip that back into scene co-ords before giving it to the  
painter
	QPainterPath scenePath = mapToScene(path);

	// neither setting the colours alpha or the painter's opacity seems  
to have any effect
	QColor fillColour(0, 0, 0, 0.3);
	painter->setOpacity(0.3);
	painter->fillPath(scenePath, fillColour);
}

but the fillRect() method doesn't appear to honour the opacity setting  
- total black is drawn, screen shot is here
	http://idisk.me.com/john_clayton/Public/Pictures/Skitch/Picture_2-20090901-232907.jpg

I expected the black are to be opaque - and tips appreciated!

Thanks
--
John Clayton

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090901/c98415b7/attachment.html 


More information about the Qt-interest-old mailing list