summaryrefslogtreecommitdiffstats
path: root/tests/manual/examples/svgwidget/main.cpp
blob: 0a536ce1805aa6e0154cdfedb46cdc1e9778e9e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QStringList>
#include <QTabWidget>
#include <QSvgWidget>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QCoreApplication::setApplicationName("SVG Widget");
    QGuiApplication::setApplicationDisplayName(QCoreApplication::applicationName());
    QCoreApplication::setOrganizationName("QtProject");
    QCoreApplication::setApplicationVersion(QT_VERSION_STR);

    QCommandLineParser parser;
    parser.setApplicationDescription("Qt SVG Widget");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("file", "The file to open.");
    parser.process(app);

    const QString fileName = parser.positionalArguments().value(0, QLatin1String(":/files/bubbles.svg"));

    QTabWidget top;

    auto widget = new QSvgWidget(&top);
    top.addTab(widget, "Bubbles");
    widget->load(fileName);

    auto otherWidget = new QSvgWidget(&top);
    top.addTab(otherWidget, "Spheres");
    otherWidget->load(QLatin1String(":/files/spheres.svg"));

    top.show();
    return app.exec();
}