diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-10 14:50:27 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-21 11:06:37 +0200 |
| commit | b70d8b334c4f714a046d72ea0a5f1a8378fd55b9 (patch) | |
| tree | c715f0ee50052f6f668ee9f2566456b1b0cbd809 /tools/qtpy2cpp_lib/tests/baseline/basic_test.py | |
| parent | dedfebbc438ed2f5f6869092ee10e68f9ffd8a36 (diff) | |
qtpy2cpp: Set up test infrastructure
Add test code and move the files to baseline.
Task-number: PYSIDE-1945
Pick-to: 6.3
Change-Id: I57975c774d53a4dc5f77ca671652ca32c04809de
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'tools/qtpy2cpp_lib/tests/baseline/basic_test.py')
| -rw-r--r-- | tools/qtpy2cpp_lib/tests/baseline/basic_test.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/qtpy2cpp_lib/tests/baseline/basic_test.py b/tools/qtpy2cpp_lib/tests/baseline/basic_test.py new file mode 100644 index 000000000..10dc73767 --- /dev/null +++ b/tools/qtpy2cpp_lib/tests/baseline/basic_test.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import sys + +from PySide6.QtCore import qVersion, Qt +from PySide6.QtGui import QColor, QPainter, QPaintEvent, QShortcut +from PySide6.QtWidgets import QApplication, QWidget + + +class Window(QWidget): + def __init__(self, parent: QWidget = None): + super().__init__(parent) + + def paintEvent(self, e: QPaintEvent): + self.paint("bla") + + def paint(self, what: str, color: Qt.GlobalColor = Qt.blue): + with QPainter(self) as p: + p.setPen(QColor(color)) + rect = self.rect() + w = rect.width() + h = rect.height() + p.drawLine(0, 0, w, h) + p.drawLine(0, h, w, 0) + p.drawText(rect.center(), what) + + def sum(self): + values = [1, 2, 3] + result = 0 + for v in values: + result += v + return result + + +if __name__ == '__main__': + app = QApplication(sys.argv) + window = Window() + sc = QShortcut(Qt.CTRL | Qt.Key_Q, window) + sc.activated.connect(window.close) + window.setWindowTitle("Test") + window.show() + sys.exit(app.exec()) |
