diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-09-23 17:44:19 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-09-28 07:41:36 +0000 |
commit | 6fa50ffc31fcca051c73eeaa94116f2667b9ae6b (patch) | |
tree | ca4298370d276afe10f1075c50352c80f0e218b6 /examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp | |
parent | d37a0145cdec131ef6f689310530ce92c4ba5e05 (diff) |
Fix up flawed TranslucentBackground usage in docs and examples
Following the qtbase fixes, start doing things correctly in the
QQuickWidget examples too. Remove the checkbox and use a --transparent
command line argument (like in hellogl2).
In addition --transparent --no_render_alpha can be used to verify the
most problematic case: when alpha is present and the backingstore contains
semi-transparent pixels in places where the underlying QOpenGLWidget is
opaque. Here the result must still be an opaque pixel. This was previously
ensured by a glColorMask call, now replaced by glBlendFuncSeparate in
QPlatformBackingStore.
Task-number: QTBUG-47276
Change-Id: Ia040f899405f73e95e957becee5df43683af9c39
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp')
-rw-r--r-- | examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp b/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp index dce89d6b18..078d8e7e03 100644 --- a/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp +++ b/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp @@ -47,10 +47,10 @@ #include <QLabel> #include <QQuickItem> -MainWindow::MainWindow() +MainWindow::MainWindow(bool transparency) : m_currentView(0), m_currentRootObject(0), - m_transparent(false) + m_transparent(transparency) { QVBoxLayout *layout = new QVBoxLayout; @@ -103,13 +103,6 @@ MainWindow::MainWindow() connect(m_checkboxOverlayVisible, &QCheckBox::toggled, m_overlayLabel, &QWidget::setVisible); layout->addWidget(m_checkboxOverlayVisible); - m_checkboxTransparent = new QCheckBox(tr("Transparent background in QQuickWidget")); - connect(m_radioWidget, &QCheckBox::toggled, m_checkboxTransparent, &QWidget::setEnabled); -#ifdef Q_OS_LINUX - connect(m_checkboxTransparent, &QCheckBox::toggled, this, &MainWindow::onTransparentChanged); - layout->addWidget(m_checkboxTransparent); -#endif - setLayout(layout); updateView(); @@ -170,10 +163,8 @@ void MainWindow::updateView() switchTo(QWidget::createWindowContainer(quickView)); } else if (m_state == UseWidget) { QQuickWidget *quickWidget = new QQuickWidget; - if (m_transparent) { + if (m_transparent) quickWidget->setClearColor(Qt::transparent); - quickWidget->setAttribute(Qt::WA_TranslucentBackground); - } quickWidget->setFormat(m_format); quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); connect(quickWidget, &QQuickWidget::statusChanged, this, &MainWindow::onStatusChangedWidget); @@ -186,7 +177,8 @@ void MainWindow::updateView() if (m_currentRootObject) { m_currentRootObject->setProperty("currentText", text); m_currentRootObject->setProperty("multisample", m_checkboxMultiSample->isChecked()); - m_currentRootObject->setProperty("translucency", m_transparent); + if (!QCoreApplication::arguments().contains(QStringLiteral("--no_render_alpha"))) + m_currentRootObject->setProperty("translucency", m_transparent); } m_overlayLabel->raise(); @@ -242,9 +234,3 @@ void MainWindow::onSceneGraphError(QQuickWindow::SceneGraphError error, const QS { m_labelStatus->setText(tr("Scenegraph error %1: %2").arg(error).arg(message)); } - -void MainWindow::onTransparentChanged(bool enabled) -{ - m_transparent = enabled; - updateView(); -} |