Topic: svg export with transparent background color?

Dear All,

While searching for a high quality schematic editor, I hit upon qet yesterday. I installed 0.8, created a small user collection of 25 elements and a small schematic. I was really impressed of what I found. Great job.

When I exported my small schematic to an svg file, I noticed the "9/16" bounding box issue that will be fixed as I read in 0.10. I also noticed that the white drawing background is correctly included with the exported svg file. However, such a background can turn out to be inconvenient, if an svg export is supposed to be included e.g. on a LibreOffice impress presentation slide with different background color. In this case the white background of the svg file will cut out a large white rectangle on the presentation slide. Of course, I can set the fill-opacity in the exported svg file manually to "0",

<g fill="#ffffff" fill-opacity="1" stroke="none" transform="matrix(0.75,0,0,0.75,-159.727,-160.5)"
font-family="Ubuntu" font-size="10" font-weight="400" font-style="normal">

however, it would be more convenient, if the background color could be turned off (set to transparent) by means of the export dialog. I have checked (compiled) 0.9 and installed also the nightly 0.10, but did not find a corresponding option. So, is it possible to add this feature to the new revision 0.10?

Regards
Tom

Re: svg export with transparent background color?

Hello Tom,

as far as I can see:
All graphical elements of the diagram are completely processed by a QT library function. So if you want to change the background color of the SVG export, you have to change the background color of the folio. This is not possible at the moment.
Due to the small number of active developers, I see little chance of this being implemented in the foreseeable future.

Best regards
  plc-user

Re: svg export with transparent background color?

Hi Tom and thanks for yours compliments,

https://forum.qt.io/topic/124111/how-to … g-using-qt
https://stackoverflow.com/questions/151 … -svg-in-qt
https://forum.qt.io/topic/14762/solved- … ckground/4


https://doc.qt.io/qt-6/qsvggenerator.html

I saw you use Linux then, it should be easier to create a small batch script for batch processing based on find and sed?

Personally, I wouldn't calculate a script for so little. With KDE's Kate editor, you can search and replace one occurrence by another in all the files in a folder or in sub folders in 3 seconds.

Best regards,
Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: svg export with transparent background color?

scorpio810 wrote:

Personally, I wouldn't calculate a script for so little. With KDE's Kate editor, you can search and replace one occurrence by another in all the files in a folder or in sub folders in 3 seconds.

cross-platform with DoubleCommander's search function!

Re: svg export with transparent background color?

https://kate-editor.org/en/get-it/

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: svg export with transparent background color?

@plc-user and scorpio810

Thanks for your quick reply.
Yes #1, it is not an issue but just a nice-to-have. And I can manually or assisted by a script remove the background color, if needed.
Yes #2, I already tried to modify the background color of the folio in the source code of 0.90. However, it turned out to be not as simple as replacing it by Qt::transparent :-). Unfortunately, I am neither very experienced in c++ nor in Qt.
Yes #3, I am running Linux Mint Mate 21.3 and are familiar with scripts and advanced editors as e.g. kate. However, for such small modifications I still prefer vim :-).

Good night
Tom

7 (edited by Tom789 2024-03-26 23:14:52)

Re: svg export with transparent background color?

Follow-up:

I found a simple way, to implement a transparent background that is automatically inherited to an svg export.
qet 0.90: qetdiagrameditor.cpp: 361-362

// Diagram::background_color = checked ? Qt::darkGray : Qt::white;
Diagram::background_color = checked ? Qt::transparent : Qt::white;

I just commented the original line 361 out and replaced "Qt::darkGray" by "Qt::transparent" in line 362. Now, when I use the new white/gray background toggle button on a folio and select the gray backgound, I get a transparent background.

Nice
Tom

P.S.: Here is an example.

Post's attachments

Attachment icon 1_diagram.svg 16.57 kb, 18 downloads since 2024-03-26 

8 (edited by plc-user 2024-03-30 22:36:12)

Re: svg export with transparent background color?

The menu a good place to try out whether setting of transparency works in principle! But the developer must have had something else in mind for this menu item than the SVG export...
For this function a new Checkbox in the export-dialog should be introduced.

Maybe with the sourcecode I uploaded to my github-repository?
https://github.com/plc-user/qelectrotech-source-mirror
(can create a pull-request...)

EDITED this post and removed the diff from here because it grew bigger and bigger...  nomicons/wink

EDITED AGAIN:
Setting and function is already available in Version 0.100 (DEV)  nomicons/smile

Re: svg export with transparent background color?

The folio background to grey (button is in the upper tool bar) was added not for your eyes but for different raisons:

Like use white element for xrefs, BOM, etc, or draw invisible line, example:

https://qelectrotech.org/forum/viewtopic.php?id=1139

https://github.com/qelectrotech/qelectr … 7b6dc697e7

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."