Android 从Qt快速控制2加载下一屏幕/应用程序窗口
我对Qt quick control 2开发非常陌生。我正在为android开发一个跨平台的应用程序。我正在从C++代码中加载新的屏幕作为贝娄Android 从Qt快速控制2加载下一屏幕/应用程序窗口,android,c++,qt,qtquickcontrols2,Android,C++,Qt,Qtquickcontrols2,我对Qt quick control 2开发非常陌生。我正在为android开发一个跨平台的应用程序。我正在从C++代码中加载新的屏幕作为贝娄 int main(int argc, char *argv[]) { QApplication应用程序(argc、argv); qqmlaplicationengine; 通信类mCommunication; engine.rootContext()->setContextProperty(“CommunicatorClass”、&mCommunica
int main(int argc, char *argv[])
{
QApplication应用程序(argc、argv);
qqmlaplicationengine;
通信类mCommunication;
engine.rootContext()->setContextProperty(“CommunicatorClass”、&mCommunication);
engine.load(QUrl(QStringLiteral(“qrc:/main.qml”));
QObject*topLevel=engine.rootObjects().value(0);
QQuickWindow*window=qobject_cast(顶级);
窗口->显示();
返回app.exec();
}
这将加载我的登录屏幕。一旦用户提交用户名,密码应用程序在C++代码中也会被验证。因此,QML与C++之间的通信工作正常。现在我想在验证用户名和密码时加载下一个屏幕。请告诉我如何在这种情况下继续进行,因为我对C++和Qt快速控制都很新,2 < P>一个选项是在C++中导出的对象上有一个属性,该属性引用“当前屏幕”。 然后,main.qml中的代码可以使用
加载程序
加载该屏幕
在C++中看起来有点像这样:
class CommunicatorClass : public QObject
{
Q_OBJECT
Q_PROPERTY(QString currentScreen READ currentScreen NOTIFY currentScreenChanged);
public:
QString currentScreen() const;
signals:
void currentScreenChanged();
};
在QML中,有点像这样:
Window {
Loader {
source: CommunicatorClass.currentScreen
}
}
假设currentScreen
属性引用相对于main.QML的QML文件
Window {
Loader {
source: CommunicatorClass.currentScreen
}
}