2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2024-02-02 13:36:10 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2013-12-18 13:48:22 +00:00
|
|
|
|
Mark all of Qt as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses in this and some other modules is still
extremely high, too high for anyone to tackle in a short amount of
time. Even if they're not concentrated in just a few TUs, we need to
make progress on a global QT_NO_FOREACH default, so grab the nettle
and stick to our strategy:
Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too).
In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the
#undef QT_NO_FOREACH to indicate that these actually test the macro.
Task-number: QTBUG-115839
Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-08-07 15:59:46 +00:00
|
|
|
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
|
|
|
|
|
2013-12-18 13:48:22 +00:00
|
|
|
#include "openglwidget.h"
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QMdiArea>
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
#include <QMdiSubWindow>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QMainWindow>
|
2013-12-18 13:48:22 +00:00
|
|
|
#include <QLCDNumber>
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
#include <QScrollArea>
|
|
|
|
#include <QScrollBar>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QLabel>
|
2013-12-18 13:48:22 +00:00
|
|
|
#include <QTimer>
|
2014-06-20 09:58:34 +00:00
|
|
|
#include <QSurfaceFormat>
|
|
|
|
#include <QDebug>
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
#include <private/qwindow_p.h>
|
|
|
|
|
|
|
|
class Tools : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-07-06 14:37:47 +00:00
|
|
|
Tools(QWidget *root, QWidget *widgetToTurn, const QWidgetList &glwidgets)
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
: m_root(root), m_widgetToTurn(widgetToTurn), m_glWidgets(glwidgets) { }
|
|
|
|
void dump();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void turnNative();
|
|
|
|
void hideShowAllGL();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void aboutToShowGLWidgets();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void dumpWidget(QWidget *w, int indent = 0);
|
|
|
|
|
|
|
|
QWidget *m_root;
|
|
|
|
QWidget *m_widgetToTurn;
|
2020-07-06 14:37:47 +00:00
|
|
|
QWidgetList m_glWidgets;
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void Tools::turnNative()
|
|
|
|
{
|
|
|
|
qDebug("Turning into native");
|
|
|
|
m_widgetToTurn->winId();
|
|
|
|
dump();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Tools::hideShowAllGL()
|
|
|
|
{
|
|
|
|
if (m_glWidgets[0]->isVisible()) {
|
|
|
|
qDebug("Hiding all render-to-texture widgets");
|
|
|
|
foreach (QWidget *w, m_glWidgets)
|
|
|
|
w->hide();
|
|
|
|
} else {
|
|
|
|
qDebug("Showing all render-to-texture widgets");
|
|
|
|
emit aboutToShowGLWidgets();
|
|
|
|
foreach (QWidget *w, m_glWidgets)
|
|
|
|
w->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Tools::dump()
|
|
|
|
{
|
|
|
|
qDebug() << "Widget hierarchy";
|
|
|
|
dumpWidget(m_root);
|
|
|
|
qDebug() << "========";
|
|
|
|
}
|
|
|
|
|
|
|
|
void Tools::dumpWidget(QWidget *w, int indent)
|
|
|
|
{
|
|
|
|
QString indentStr;
|
|
|
|
indentStr.fill(' ', indent);
|
|
|
|
qDebug().noquote() << indentStr << w << "winId =" << w->internalWinId();
|
|
|
|
foreach (QObject *obj, w->children()) {
|
|
|
|
if (QWidget *cw = qobject_cast<QWidget *>(obj))
|
|
|
|
dumpWidget(cw, indent + 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TabWidgetResetter : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
TabWidgetResetter(QTabWidget *tw) : m_tw(tw) { }
|
|
|
|
public slots:
|
|
|
|
void reset() { m_tw->setCurrentIndex(0); }
|
|
|
|
private:
|
|
|
|
QTabWidget *m_tw;
|
|
|
|
};
|
2013-12-18 13:48:22 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
if (argc > 1 && !strcmp(argv[1], "--sharecontext")) {
|
|
|
|
qDebug("Requesting all contexts to share");
|
|
|
|
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
|
|
|
}
|
|
|
|
|
2013-12-18 13:48:22 +00:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
|
2014-06-20 09:58:34 +00:00
|
|
|
QSurfaceFormat format;
|
|
|
|
if (QCoreApplication::arguments().contains(QLatin1String("--multisample")))
|
|
|
|
format.setSamples(4);
|
|
|
|
if (QCoreApplication::arguments().contains(QLatin1String("--coreprofile"))) {
|
|
|
|
format.setVersion(3, 2);
|
|
|
|
format.setProfile(QSurfaceFormat::CoreProfile);
|
|
|
|
}
|
|
|
|
qDebug() << "Requesting" << format;
|
|
|
|
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
QMainWindow wnd;
|
|
|
|
wnd.setObjectName("Main Window");
|
|
|
|
wnd.resize(1024, 768);
|
|
|
|
|
|
|
|
QMdiArea *w = new QMdiArea;
|
|
|
|
w->setObjectName("MDI area");
|
|
|
|
w->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
wnd.setCentralWidget(w);
|
2013-12-18 13:48:22 +00:00
|
|
|
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
OpenGLWidget *glw = new OpenGLWidget(33, QVector3D(0, 0, 1));
|
|
|
|
glw->setObjectName("First GL Widget with 33 ms timer");
|
2014-06-20 09:58:34 +00:00
|
|
|
glw->setFormat(format);
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
glw->setMinimumSize(100, 100);
|
|
|
|
QMdiSubWindow *sw = w->addSubWindow(glw);
|
|
|
|
sw->setObjectName("First MDI Sub-Window");
|
|
|
|
sw->setWindowTitle("33 ms timer");
|
2013-12-18 13:48:22 +00:00
|
|
|
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
OpenGLWidget *glw2 = new OpenGLWidget(16);
|
|
|
|
glw2->setObjectName("Second GL Widget with 16 ms timer");
|
2014-06-20 09:58:34 +00:00
|
|
|
glw2->setFormat(format);
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
glw2->setMinimumSize(100, 100);
|
|
|
|
QOpenGLWidget *glw22 = new OpenGLWidget(16);
|
|
|
|
glw22->setObjectName("Second #2 GLWidget");
|
|
|
|
glw22->setParent(glw2);
|
|
|
|
glw22->resize(40, 40);
|
|
|
|
sw = w->addSubWindow(glw2);
|
|
|
|
sw->setObjectName("Second MDI Sub-Window");
|
|
|
|
sw->setWindowTitle("16 ms timer");
|
|
|
|
|
|
|
|
OpenGLWidget *glw3 = new OpenGLWidget(0); // trigger updates continuously, no timer
|
|
|
|
glw3->setObjectName("GL widget in scroll area (possibly native)");
|
|
|
|
glw3->setFormat(format);
|
|
|
|
glw3->setFixedSize(600, 600);
|
2016-01-27 17:12:44 +00:00
|
|
|
OpenGLWidget *glw3child = new OpenGLWidget(0);
|
|
|
|
const float glw3ClearColor[] = { 0.5f, 0.2f, 0.8f };
|
|
|
|
glw3child->setClearColor(glw3ClearColor);
|
|
|
|
glw3child->setObjectName("Child widget of GL Widget in scroll area");
|
|
|
|
glw3child->setFormat(format);
|
|
|
|
glw3child->setParent(glw3);
|
|
|
|
glw3child->setGeometry(500, 500, 100, 100); // lower right corner of parent
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
QScrollArea *sa = new QScrollArea;
|
|
|
|
sa->setWidget(glw3);
|
|
|
|
sa->setMinimumSize(100, 100);
|
|
|
|
sa->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
sw = w->addSubWindow(sa);
|
|
|
|
sw->setObjectName("MDI Sub-Window for scroll area");
|
|
|
|
sw->setWindowTitle("Cont. update");
|
|
|
|
sw->resize(300, 300);
|
|
|
|
sa->verticalScrollBar()->setValue(300);
|
2013-12-18 13:48:22 +00:00
|
|
|
|
|
|
|
QLCDNumber *lcd = new QLCDNumber;
|
|
|
|
lcd->display(1337);
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
lcd->setMinimumSize(300, 100);
|
|
|
|
sw = w->addSubWindow(lcd);
|
|
|
|
sw->setObjectName("MDI Sub-Window for LCD widget");
|
|
|
|
sw->setWindowTitle("Ordinary widget");
|
|
|
|
|
|
|
|
QTabWidget *tw = new QTabWidget;
|
|
|
|
QOpenGLWidget *glw4 = new OpenGLWidget(16, QVector3D(1, 0, 0));
|
|
|
|
glw4->setObjectName("GL widget in tab widget");
|
|
|
|
tw->addTab(glw4, "OpenGL");
|
|
|
|
QLabel *label = new QLabel("Another tab");
|
|
|
|
tw->addTab(label, "Not OpenGL");
|
|
|
|
tw->setMinimumSize(100, 100);
|
|
|
|
sw = w->addSubWindow(tw);
|
|
|
|
sw->setObjectName("MDI Sub-Window for tab widget");
|
|
|
|
sw->setWindowTitle("Tabs");
|
2013-12-18 13:48:22 +00:00
|
|
|
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
TabWidgetResetter twr(tw);
|
2020-07-06 14:37:47 +00:00
|
|
|
Tools t(&wnd, glw3, QWidgetList { glw, glw2, glw3, glw4 });
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
QObject::connect(&t, SIGNAL(aboutToShowGLWidgets()), &twr, SLOT(reset()));
|
|
|
|
QMenu *toolsMenu = wnd.menuBar()->addMenu("&Tools");
|
|
|
|
toolsMenu->addAction("&Turn widgets (or some parent) into native", &t, SLOT(turnNative()));
|
|
|
|
toolsMenu->addAction("&Hide/show all OpenGL widgets", &t, SLOT(hideShowAllGL()));
|
|
|
|
|
|
|
|
wnd.show();
|
2013-12-18 13:48:22 +00:00
|
|
|
|
2014-06-20 09:58:34 +00:00
|
|
|
if (glw->isValid())
|
|
|
|
qDebug() << "Got" << glw->format();
|
|
|
|
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
t.dump();
|
|
|
|
|
2013-12-18 13:48:22 +00:00
|
|
|
return a.exec();
|
|
|
|
}
|
Support mixing native child widgets with texture-based ones
Currently QOpenGLWidget and QQuickWidget do not support having native
child widgets inside the same top-level window. In some cases this is
inevitable, f.ex. multimedia may require native windows when used from
widget apps. winId() calls made for various (valid or invalid) reasons
are also problematic.
There are no blockers for supporting this setup, however. By storing
multiple texture lists (one for each subtree where the root is a
native widget), adding the missing markDirtyOnScreen calls, letting
each native widget access the correct texture list (i.e. the one
corresponding to its children) when they are (separately) flushed, and
fixing composeAndFlush() to take the update region and the (native
child) offset into account, it can all be made functional.
The change also fixes the issue of keeping GL-based compositing
enabled even after all render-to-texture widgets in the window become
hidden. Due to the changes of how such widgets are gathered,
composeAndFlush() is not invoked anymore when no such widgets are
discovered for a given native parent. This is great since having
compositing enabled infinitely is an issue for applications like Qt
Creator that implement certain views with QQuickWidgets but cannot
afford the cost of texture uploads in other places (e.g. for the text
editor) on slower machines.
The openglwidget manual test is greatly enhanced to test various
situations (MDI, scroll areas, tab widgets, QOpenGLWidget as native
child, QOpenGLWidget with non-tlw native parent, etc.)
Task-number: QTBUG-48130
Task-number: QTBUG-49172
Change-Id: Iad098359c8bcf749f01c050da0853415e1550eda
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-11-03 10:41:01 +00:00
|
|
|
|
|
|
|
#include "main.moc"
|