How to use SVG
-
Qt version 4.14.2 (That is what it says in the "About")
I don't understand something, I just recently downloaded Qt. When I downloaded Qt I selected the Qt 6 version but now as you told me to look at the version it says 4.14,2. What is going on I am very confused. Did I make a mistake in the download process?
-
No that's the Qt Creator version. There's no Qt 4.14.
You have to take a look at the kit you are using.
-
It was introduced from 4.1.
https://doc.qt.io/qt-5/qsvgwidget.html
QT += core gui widgets svg <=== you need widgets as well for qsvgwidgetIf you simply need a QPixmap from a svg source for other widgets, use QSvgRenderer to paint one.
-
Drop the C++ CONFIG, you do not need that currently.
You should also consider updating to the latest Qt 6.1.
-
-
Hi
Else a sure bet is installing Qt5.15.
While v6 does offer new things
https://wiki.qt.io/New_Features_in_Qt_6.0
Its mostly if you are using QML and it still has lots of features missing planned
for some later releases. -
- Why isn't there a widget for SVG in QT Designer by default?
Too much work I would guess. To allow a Widget to be used in design time, a plugin must be made and maintained across many Designers.
And QSvgWidget doesn't have any properties to set at Design time. (besides the svg file) so I gues sit was
not worth the effort.You can use the Producer Promote feature to allow a Qwidget as a place holder in Designer and then app is run its
the SVG one. -
Hi
Its very handy.In your use case you place a QWidget on the form, right-click and choose to promote.
Then tell it QSvgWidget for class name and it will guess on QSvgWidget.h
Then press Add (+), then then promote.https://doc.qt.io/qt-5/designer-using-custom-widgets.html
Do note:
Accessing it via Ui-> is possible and you can call the real functions from code, just like any other widget. -
So, if I want to create a custom widget for SVG, how can I do that? Is there an example that I can follow for promoting a widget to SVG?
(I ask this because I really want to use SVG as default and I need a solution.)
(I am also a beginner so I have no idea where to start :) )