我有两个应用程序窗口,我想在附加的代码中打开第二个这样的窗口。
我有几个问题: 1.通过打开第二个窗口,这会创建相当于一个Android“活动”吗?
如果按下后退按钮会返回上一个应用程序窗口吗?像Android活动一样?
如果2为假,那么这是最好的做法吗?
main.qml
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
ApplicationWindow {
id:window
title: qsTr("Hello World")
width: 640
height: 480
visible: true
Rectangle{
anchors.fill:parent
color:"blue"
}
Rectangle{
width:parent.width/6
height:width/3
anchors.centerIn:parent
MouseArea{
anchors.fill:parent
onClicked:{
var component = Qt.createComponent("Two.qml");
if (component.status == Component.Ready)
component.createObject(window, {});
}
}
}
}
Two.qml
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
ApplicationWindow {
id:window
title: qsTr("Hello World")
width: 640
height: 480
visible: true
Rectangle{
anchors.fill:parent
color:"red"
}
}
当我点击矩形打开第二个窗口时,我收到以下错误:
W/Adreno-EGL(25103): <qeglDrvAPI_eglSwapBuffers:3556>: EGL_BAD_CONTEXT
W/Qt (25103): (null):0 ((null)): QEGLPlatformContext::swapBuffers(): eglError: 12294, this: 0x6234de38