File: qimageitemtest.cpp

package info (click to toggle)
kf6-kdeclarative 6.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,104 kB
  • sloc: cpp: 3,014; sh: 18; makefile: 7
file content (34 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (2)
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
/*
    SPDX-FileCopyrightText: 2011 Marco Martin <mart@gmail.com>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include <QGuiApplication>
#include <QQmlContext>
#include <QQuickView>

#include <qtestcase.h>

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QQuickView view;
    QQmlContext *context = view.rootContext();

    QImage image;
    if (app.devicePixelRatio() < 2) {
        image = QImage(QFINDTESTDATA("testimage.png"));
    } else {
        image = QImage(QFINDTESTDATA("testimage@2x.png"));
        image.setDevicePixelRatio(2);
    }

    context->setContextProperty(QStringLiteral("testImage"), image);

    view.setSource(QUrl::fromLocalFile(QFINDTESTDATA("qimageitemtest.qml")));
    view.show();

    return app.exec();
}