diff options
| author | Even Oscar Andersen <even.oscar.andersen@qt.io> | 2024-06-06 14:57:14 +0200 |
|---|---|---|
| committer | Even Oscar Andersen <even.oscar.andersen@qt.io> | 2024-06-13 19:33:21 +0200 |
| commit | 1b220e1db85dd332fe8c1eb8efd97dd302f9cee4 (patch) | |
| tree | e575ac93155ed5810d7bd0f0f4be34c7e04896ef /tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp | |
| parent | 1943183282defdbc846813e4ceb66c1eec28fec5 (diff) | |
wasm: Fix handling of native windows
There are two problems
1) internal (not toplevel) windows needs to have the frameLess attribute
set. Without this attribute the window is not visible
2) The backingstore needs to use the correct window, if not the
symptoms are that the display is not always correctly updated.
Seen in the qtdoc/examples/demos/documentviewer demo
Fixes: QTBUG-125856
Change-Id: I040d963c0c130214cc70a607090faa006c02f981
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp')
| -rw-r--r-- | tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp b/tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp index 365fc74a34e..75e23cecdaf 100644 --- a/tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp +++ b/tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp @@ -16,6 +16,10 @@ #include <QApplication> #include <QDialog> #include <QSysInfo> +#include <QTreeView> +#include <QFileSystemModel> +#include <QScrollArea> +#include <QVBoxLayout> #include <QOpenGLWindow> #include <QOpenGLFunctions> @@ -389,6 +393,7 @@ public: void make(const std::string &name) { auto widget = std::make_shared<TestWidget>(); + widget->setWindowTitle("Dialog"); auto *lineEdit = new QLineEdit(widget.get()); widget->setMinimumSize(200, 200); @@ -401,6 +406,38 @@ public: m_widgets[name] = widget; m_lineEdits[name] = lineEdit; } + void makeNative(const std::string &name) + { + auto widget = std::make_shared<TestWidget>(); + widget->setWindowTitle("Dialog"); + auto *lineEdit = new QLineEdit(); + + widget->setMinimumSize(200, 200); + widget->setMaximumSize(200, 200); + widget->setGeometry(0, m_widgetY, 200, 200); + m_widgetY += 200; + + lineEdit->setText("Hello world"); + + m_widgets[name] = widget; + m_lineEdits[name] = lineEdit; + + QFileSystemModel *model = new QFileSystemModel; + model->setRootPath(QDir::currentPath()); + + auto *scrollArea = new QScrollArea(); + auto *layout = new QVBoxLayout(widget.get()); + auto *treeView = new QTreeView(scrollArea); + treeView->setModel(model); + + layout->addWidget(lineEdit); + layout->addWidget(scrollArea); + + treeView->setAttribute(Qt::WA_NativeWindow); + scrollArea->setAttribute(Qt::WA_NativeWindow); + lineEdit->setAttribute(Qt::WA_NativeWindow); + widget->setAttribute(Qt::WA_NativeWindow); + } private: using TestWidgetPtr = std::shared_ptr<TestWidget>; @@ -503,6 +540,11 @@ void createWidget(const std::string &name) WidgetStorage::getInstance()->make(name); } +void createNativeWidget(const std::string &name) +{ + WidgetStorage::getInstance()->makeNative(name); +} + void setWidgetNoFocusShow(const std::string &name) { auto w = WidgetStorage::getInstance()->findWidget(name); @@ -678,6 +720,7 @@ EMSCRIPTEN_BINDINGS(qwasmwindow) emscripten::function("getOpenGLColorAt_0_0", &getOpenGLColorAt_0_0); emscripten::function("createWidget", &createWidget); + emscripten::function("createNativeWidget", &createNativeWidget); emscripten::function("setWidgetNoFocusShow", &setWidgetNoFocusShow); emscripten::function("showWidget", &showWidget); emscripten::function("activateWidget", &activateWidget); |
