Making the sheet displaying QGraphicsItem CanvasItem of Calligra transparent on a GraphicsScene

Philip Van Hoof philip at codeminded.be
Fri Nov 30 13:14:12 GMT 2012


Hi there,

I'm trying to make the cells of a spreadsheet document which I have
loaded using sheets/part/CanvasItem.h, which is a GraphicsItem,
transparent.

I tried the following code, but although the result is that the color of
all cells changes, the color it uses isn't transparent but white. Or
perhaps it is transparent but there is something white behind the cells
anyway.

QGraphicsRectItem rect;

Part *part = new Part(0);
Doc *doc = new Doc(part);
part->setDocument(doc);

CanvasItem *m_canvas = new CanvasItem (doc);
m_canvas->setParentItem(&rect);

Sheet *sheet = m_canvas->activeSheet();

Calligra::Sheets::Region region = Calligra::Sheets::Region(1, 1, KS_colMax, KS_rowMax);

Style style;
QBrush brush;
brush.setColor(Qt::transparent);
style.setBackgroundBrush(brush);
style.setBackgroundColor(Qt::transparent);

Sheet::BackgroundImageProperties props = sheet->backgroundImageProperties();
props.opacity = 0;
sheet->setBackgroundImageProperties( props );

CellStorage *cells = sheet->cellStorage();
cells->setStyle(region, style);

scene.addItem(&rect);

Does somebody know how I can make it be truly transparent? Is there
something being drawn behind the CellView instances that is white? Like
a background maybe?

I noticed the existence of the API sheet->setBackgroundImageProperties.
As you can see above I tried using it, but it didn't change much.

If I would have to patch Calligra to make this effect possible, where
should I start looking?

Kind regards,

Philip



-- 


Philip Van Hoof
Software developer
Codeminded BVBA - http://codeminded.be




More information about the calligra-devel mailing list