On Fri, 30 Nov 2012, Philip Van Hoof wrote:
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.
Hm... let's see. The basic painting code is in CanvasBase.cpp, where line
477 says
painter->fillRect(paintRect, painter->background());
But where is the background on the QPainter object set... I think we need
Mek to figure that out. You could hack your version of sheets' canvasbase
here to something like
Qt::BGMode bgMode = painter->backgroundMode();
painter->setBackgroundMode(Qt::TransparentMode();
...
painter->setBackgroundMode(bgMode);
sheet->backgroundImageProperties are something different, I think -- it
must be meant to show an actual image as specified by the document, like a
watermark.
QGraphicsItem::setOpacity also isn't what you need, since that would set
the opacity for everything including the cell foregrounds.
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
_______________________________________________
calligra-devel mailing list
calligra-devel@kde.org
https://mail.kde.org/mailman/listinfo/calligra-devel
_______________________________________________
calligra-devel mailing list
calligra-devel@kde.org
https://mail.kde.org/mailman/listinfo/calligra-devel