summaryrefslogtreecommitdiffstats
path: root/examples/widgets
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-06-26 17:55:21 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-06-29 03:13:10 +0200
commitcd7995de57321854b1da01e07ba49e82520abfe3 (patch)
tree9101a3e5634c86852ceba3e5eed6c3c6550b2f2a /examples/widgets
parent993cbef7f41446b550c28fcbb30c5c4a5b40d19f (diff)
Move windowcontainer example to manual test
Pick-to: 6.5 6.6 Change-Id: I68b866bcc2659b90aad2c10dc06240674bf4a826 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'examples/widgets')
-rw-r--r--examples/widgets/CMakeLists.txt3
-rw-r--r--examples/widgets/widgets.pro3
-rw-r--r--examples/widgets/windowcontainer/CMakeLists.txt42
-rw-r--r--examples/widgets/windowcontainer/windowcontainer.cpp136
-rw-r--r--examples/widgets/windowcontainer/windowcontainer.pro9
5 files changed, 0 insertions, 193 deletions
diff --git a/examples/widgets/CMakeLists.txt b/examples/widgets/CMakeLists.txt
index c5b81e81a4..c5d3de8b34 100644
--- a/examples/widgets/CMakeLists.txt
+++ b/examples/widgets/CMakeLists.txt
@@ -26,6 +26,3 @@ endif()
if(QT_FEATURE_cursor)
add_subdirectory(mainwindows)
endif()
-if(QT_FEATURE_opengl AND TARGET Qt6::Gui)
- qt_internal_add_example(windowcontainer)
-endif()
diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro
index 3d8a6d38d3..8818582105 100644
--- a/examples/widgets/widgets.pro
+++ b/examples/widgets/widgets.pro
@@ -21,9 +21,6 @@ SUBDIRS = \
tutorials \
widgets
-qtHaveModule(gui):qtConfig(opengl): \
- SUBDIRS += windowcontainer
-
contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows
!qtConfig(draganddrop): SUBDIRS -= draganddrop
!qtConfig(animation): SUBDIRS -= animation
diff --git a/examples/widgets/windowcontainer/CMakeLists.txt b/examples/widgets/windowcontainer/CMakeLists.txt
deleted file mode 100644
index 925dbfc366..0000000000
--- a/examples/widgets/windowcontainer/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(windowcontainer LANGUAGES CXX)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/windowcontainer")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL Widgets)
-
-qt_standard_project_setup()
-
-qt_add_executable(windowcontainer
- ../../opengl/openglwindow/openglwindow.cpp ../../opengl/openglwindow/openglwindow.h
- windowcontainer.cpp
-)
-
-set_target_properties(windowcontainer PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_include_directories(windowcontainer PRIVATE
- ../../opengl/openglwindow
-)
-
-target_link_libraries(windowcontainer PRIVATE
- Qt6::Core
- Qt6::Gui
- Qt6::OpenGL
- Qt6::Widgets
-)
-
-install(TARGETS windowcontainer
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/windowcontainer/windowcontainer.cpp b/examples/widgets/windowcontainer/windowcontainer.cpp
deleted file mode 100644
index fa66684294..0000000000
--- a/examples/widgets/windowcontainer/windowcontainer.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "openglwindow.h"
-
-#include <QApplication>
-#include <QFocusEvent>
-#include <QHBoxLayout>
-#include <QKeyEvent>
-#include <QLineEdit>
-#include <QMouseEvent>
-#include <QPainter>
-#include <QWidget>
-
-
-// Making use of the class from the openglwindow example
-class Window : public OpenGLWindow
-{
- Q_OBJECT
-public:
- using OpenGLWindow::OpenGLWindow;
-
- void render(QPainter *p) override
- {
- QLinearGradient g(0, 0, 0, height());
- g.setColorAt(0, QColor("lightsteelblue"));
- g.setColorAt(1, Qt::black);
- p->fillRect(0, 0, width(), height(), g);
-
- p->setPen(Qt::white);
-
- p->drawText(20, 30, QLatin1String("This is an OpenGL based QWindow"));
-
- if (m_key.trimmed().length() > 0) {
- QRect bounds = p->boundingRect(QRect(0, 0, width(), height()), Qt::AlignTop | Qt::AlignLeft, m_key);
- p->save();
- p->translate(width() / 2.0, height() / 2.0);
- p->scale(10, 10);
- p->translate(-bounds.width() / 2.0, -bounds.height() / 2.0);
- p->drawText(bounds, Qt::AlignCenter, m_key);
- p->restore();
- }
-
- if (m_focus)
- p->drawText(20, height() - 20, QLatin1String("Window has focus!"));
-
- p->setRenderHint(QPainter::Antialiasing);
- p->drawPolyline(m_polygon);
- }
-
- void mousePressEvent(QMouseEvent *e) override
- {
- if (!m_mouseDown) {
- m_mouseDown = true;
- m_polygon.clear();
- m_polygon.append(e->position().toPoint());
- renderLater();
- }
- }
-
- void mouseMoveEvent(QMouseEvent *e) override
- {
- if (m_mouseDown) {
- m_polygon.append(e->position().toPoint());
- renderLater();
- }
- }
-
- void mouseReleaseEvent(QMouseEvent *e) override
- {
- if (m_mouseDown) {
- m_mouseDown = false;
- m_polygon.append(e->position().toPoint());
- renderLater();
- }
- }
-
- void focusInEvent(QFocusEvent *) override
- {
- m_focus = true;
- renderLater();
- }
-
- void focusOutEvent(QFocusEvent *) override
- {
- m_focus = false;
- m_polygon.clear();
- renderLater();
- }
-
- void keyPressEvent(QKeyEvent *e) override
- {
- m_key = e->text();
- renderLater();
- }
-
- void keyReleaseEvent(QKeyEvent *) override
- {
- m_key = QString();
- renderLater();
- }
-private:
- QPolygon m_polygon;
- QString m_key;
- bool m_mouseDown = false;
- bool m_focus = false;
-};
-
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout(widget);
-
- Window *window = new Window;
-
- QWidget *container = QWidget::createWindowContainer(window);
- container->setMinimumSize(300, 300);
- container->setMaximumSize(600, 600);
- container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- container->setFocusPolicy(Qt::StrongFocus);
-
- window->setGeometry(100, 100, 300, 200);
-
- layout->addWidget(new QLineEdit(QLatin1String("A QLineEdit")));
- layout->addWidget(container);
- layout->addWidget(new QLineEdit(QLatin1String("A QLabel")));
-
- widget->show();
-
- return app.exec();
-}
-
-#include "windowcontainer.moc"
diff --git a/examples/widgets/windowcontainer/windowcontainer.pro b/examples/widgets/windowcontainer/windowcontainer.pro
deleted file mode 100644
index 664ac938a2..0000000000
--- a/examples/widgets/windowcontainer/windowcontainer.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-SOURCES = windowcontainer.cpp
-
-QT += widgets
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/windowcontainer
-INSTALLS += target
-
-include(../../opengl/openglwindow/openglwindow.pri)