aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-08-30 14:39:40 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2023-09-04 14:55:11 +0200
commit33ab96f8e3ce6571774a541b3adbdaab679a0184 (patch)
treead16c91fb84ee7fd3fecad035b9c08dd636ba9d1 /examples
parent8c80dc34578049de7f20f0c06aff58fc1d68e2d4 (diff)
rendercontrol_rhi example: Add a checkbox to exercise mirrorVertically
Change-Id: Ia8ff0162db51e9e7c6eb6fb38df1ca28a47935fc Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/rendercontrol/rendercontrol_rhi/main.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp b/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp
index 3bc40400e0..f58ce1868c 100644
--- a/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp
+++ b/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp
@@ -14,6 +14,7 @@
#include <QGridLayout>
#include <QPushButton>
#include <QSlider>
+#include <QCheckBox>
#include <QScrollBar>
#include <QListWidget>
#include <QPainter>
@@ -112,6 +113,8 @@ public:
ImageLabel *m_focus = nullptr;
QLabel *m_fullSizeViewerWindow = nullptr;
QVector<QImage> m_frames;
+
+ bool m_mirrorVertically = false;
};
MainWindow::MainWindow(AnimationDriver *animationDriver)
@@ -150,6 +153,12 @@ MainWindow::MainWindow(AnimationDriver *animationDriver)
controlLayout->addWidget(animLabel);
controlLayout->addWidget(animSlider);
+ QCheckBox *mirrorCheckBox = new QCheckBox(tr("Mirror vertically"));
+ QObject::connect(mirrorCheckBox, &QCheckBox::stateChanged, mirrorCheckBox, [this, mirrorCheckBox] {
+ m_mirrorVertically = mirrorCheckBox->isChecked();
+ });
+ controlLayout->addWidget(mirrorCheckBox);
+
QGridLayout *gridLayout = new QGridLayout;
vlayout->addLayout(gridLayout);
@@ -415,6 +424,11 @@ void MainWindow::render()
if (m_frameCount > 0)
stepAnimations();
+ // this is only here to communicate the possibly changed mirrorVertically flag
+ QQuickRenderTarget quickRt = QQuickRenderTarget::fromRhiRenderTarget(m_rt.get());
+ quickRt.setMirrorVertically(m_mirrorVertically);
+ m_scene->setRenderTarget(quickRt);
+
//! [render-core]
QElapsedTimer cpuTimer;
cpuTimer.start();