I have a question, I want to open new window by qml code. I found this post and try to implement it in some sample project.
code for mouse area:
MouseArea
{
id: butMouse
anchors.fill: root;
onClicked:
{
var component = Qt.createComponent("newWind.qml")
var window = component.createObject(root)
window.show();
}
}
and code for newWind.qml
ApplicationWindow {
id: newwindow
width: 100
height: 62
Text
{
text: "new one"
}
}
but when I make a click, I get in console this kind of output
W/Adreno200-EGLSUB(22206): SetSwapInterval() interval: 1 not set
W/Adreno200-EGLSUB(22206): SetSwapInterval() interval: 1 not set
W/Qt (22206): androidjnimain.cpp:545 (void setSurface(JNIEnv*, jobject, jint, jobject, jint, jint)): Can't find surface 2
W/Adreno200-EGLSUB(22206): SetSwapInterval() interval: 1 not set
W/Qt (22206): androidjnimain.cpp:545 (void setSurface(JNIEnv*, jobject, jint, jobject, jint, jint)): Can't find surface 3
W/Qt (22206): androidjnimain.cpp:545 (void setSurface(JNIEnv*, jobject, jint, jobject, jint, jint)): Can't find surface 1
When I block the screen and unblock, suddenly I can see the new screen appears. It looked for me that some action is made during process of putting screen into sleep mode.
But after searching for swapInterval I found smth like this:
Swap Interval is a means of synchronizing the swapping of the front and back frame buffers with vertical blanks (v-blank): the hardware event where the screen image is updated with data from the front framebuffer . It is a very common means of preventing frame "tearing," (seeing half of one frame and half of another) as often seen in high-motion-content graphics.
text taken from this site
and here is my question how can I solve this problem or make some workaround
Edit: to be more specific I'm running app on the real device (I tested it on sony xperia m and Samsung GT-S5830). Version of qt: Qt Creator 3.1.2 (opensource) Based on Qt 5.3.1 (GCC 4.6.1, 64 bit)
EDIT:
SOLUTION
I found this report about qt bug and this comment
"As far as I know, this is a limitation of the Android port at the moment: There can be only one OpenGL-enabled window, and it has to be created first.
When I modify the example to create a QQuickView and a QMainWindow in main(), and then later hide the mainwindow, the first QQuickView is visible. Trying to create a second QQuickView does not work."
so for me it's looks like application can have only one window in one time. I try firstly with hiding the first window, but it doesn't change nothing at all. The solution is to close the first window. This is the code which works properly for me:
MouseArea
{
id: butMouse
anchors.fill: root;
onClicked:
{
rootWindow.close();
var component = Qt.createComponent("newWind.qml")
var window = component.createObject(root)
window.show();
}
}
where rootWindow is the parent's id of first window.
If you have any problem, give a word in a comments.