[SOLVED] Problems with launching new window
-
Hello!
I am trying to launch new window. Here is the code: http://qt-project.org/forums/viewthread/30689
The problem is new window appears ONLY when i first hide app and then open it.
When i hide it app outputs:
W/Qt (14985): eglconvenience\qeglplatformcontext.cpp:319 (virtual void QEGLPlatformContext::swapBuffers(QPlatformSurface*)): QEGLPlatformContext::swapBuffers(): eglError: 12291, this: 0x53977c70 --This output from Qt5.3.0.
Qt5.3.1, 5.3.2, 5.4.0 also gave me warnings linked with EGL.Qt5.2.1 didn't open new window at all and said:
eglMakeCurrent:593 error 3002 (EGL_BAD_ACCESS)I'm running it on Android 4.2.2, Philips S308, on Asus Fonepad 7 with the same Android version this situation repeated.
Maybe you have some examples of creation new window? Or show me how to fix this error.
Help!
Thanx.
-
Android (and EGLFS) supports only one top-level window.
-
You could create - say - a plain gray top-level widget, that has your "windows" as subwidgets. That would require you to do quite a bit of rewriting here.
-
Thank you for reply!
Sierdzio, tried what you suggest and i succeded, but i have some question on my approach.
My
bq. plain gray top-level widget
is Rectangle.
I use Loader to load my main "window" qml. Then i click on MouseArea in this window to load second window qml (with the same loader id). Then i want to return to main "window" and click on second window MouseArea to load it (loader id the same), but it state is lost. I understand that.
My question: do i have to save my main "window" state when i load another "window" or i chose wrong approach (by means of Loader functionality) in the first place?
-
Your use-case now sounds like a nice candidate for "Flipable":http://doc.qt.io/qt-5/qml-qtquick-flipable.html element, or the "StackView":http://doc.qt.io/qt-5/qml-qtquick-controls-stackview.html.
A minimal change to your current approach would be this: display your first window at application start (you can even replace the Rectangle), then add your second window in this way (add this as the last child of main window, to make it's z value high enough):
@
Loader {
anchors.fill: parent // will fill the main window when set to visible
source: "path to your file"
visible: false
}
@Then, then you click on your mouse area, you can just set visible to true, and the second window will be shown. And to go back - you can send a signal from your secondary window that will be read in main and will set visible back to false. That is a bit more advanced, but I can help you with that later. Let's focus on the basics first :-)
-
[quote author="zword" date="1422633603"]bq. Android (and EGLFS) supports only one top-level window.
Is it only for QML or QT (without QML) also supports only one top-level window?[/quote]
Not even that, it is Android platform itself ;-) So yes, both QtWidgets and QtQuick support only one top-level window on Android.