Save QQmlApplicationEngine render to SVG - qt

I am using QQmlApplicationEngine to render a QML file and would like to get the QGraphicsScene in order to save the output as SVG, does anyone know how to get this?
(I would like to render my QML output to a SVG file. I have found a lot of solutions in C++ but I lack the deeper knowledge of the Qt rendering pipeline to get the correct classes from the QML.
In this link ( https://forum.qt.io/topic/6008/how-to-save-a-qgraphicsscene-to-an-svg-file/5 ) a QGraphicsScene is used as input for a QSvgGenerator to generate an SVG, thus the question.)

Related

Create QML component library

I wasn't able to create and use a QML component library by following the fragmented parts of tutorials and Qt documentation, so I'm just gonna ask somebody to answer it all at once.
I want to create a single file (located in /usr/lib/project/components.rcc), that will include all components in ~/Project/src/components/ and their child components located in ~/Projects/src/components/insertparentcomponentname/. I want to be able to use those components in normal QML code.
The question is, how can I create this file and how can I import components in it to use in QML?
( Using Qt Quick 2.0 and C++ with CMake on Arch Linux )

Use Qt Help .qhc files into QML

I would like to display .qhc files into my QML/QtQuick application, does anyone tried to do that?
I know that I can use QHelpEngine on the C++ part, but I would like to use qhc files directly on QML.

Qt Linguist: translation of text changed dynamically in tr()

I am using qt linguist and qt 5.2. I have a problem that when I add something to .ui files I can see it after lupdate in ts file but when I change name of this button dynamically in my code like:
ui->label->setText(tr("foo"));
I can't see it in ts file, is it possible to make translation in that case? How I can do this?
Basically, tr() can be detected anywhere in the codes.For ui files, linguist would detect the changes immediately, however in codes I encounterd the same problem.
Based on my experience, try to reBuilt/qmake it.
(I am using Qt4.8 & 5.1.)

How to attach png files to qwtplot

Is it possible to use png files in QwtPlot? Normally i can use svg files in my plots with QwtPlotSvgitem class but i could not succeed with these png files. Please give me a clue about that.
Regards
Probably there are several ways to do this. You don't specify what kind of image you want to draw (and where).
You might create a QwtPlotMarker (Qwt docs) with a custom QwtSymbol (Qwt docs). You can try QwtSymbol::setPixmap(). A QPixmap can be created by calling its constructor with the file name of the *.png image (Qt docs).

Styling only promoted widgets using QT Creator

I'm new to Qt and have been designing forms using Qt Creator. I've noticed that I can apply styles for specific widgets in the form's stylesheet, and it will style every widget on the form. For example "QPushButton{color: red;}" will make all the QPushButtons on the form have red text.
Is there a way to only apply styles to certain groups of widgets? For example, if I promote a QPushButton and call it MyButton, how can I set styles only for MyButtons. I would expect to be able to do something like "MyButton{color: green;}" but that doesn't seem to work.
Is there a better way to do what I'm trying to do (preferably using Qt Creator)? I can't seem to find an example of this anywhere, but maybe it's because I'm not using the correct terminology.
Thanks,
Mark
There are a lot of options for specifying selectors in style sheets. They are documented here.
One that I use (that is hinted to in the official style sheet reference document) is
|=
QPushButton[objectName|="somePrefix_"]
I use this to select items that have the same object name prefix. You could of course achieve a similar thing by applying a stylesheet to a panel containing the buttons you want to style differently but this can get tricky.
IIRC that should work, but creator might not show the preview correctly as it is not instantiating your button. Personally I think working with a global .css file that gets loaded at startup works better than applying single styles on each element in creator.
Use QApplication::setStyleSheet() to set a global stylesheet

Resources