我讓一個程序工作不同的qml文件,首先顯示一個獲取idClient的屏幕,點擊一個按鈕並發表一個帖子(它工作正常),其次,新屏幕獲取idVent,點擊一個按鈕,發表一篇文章(這也是作品),最後第三個屏幕顯示大量數據。我的問題是偶爾可能會在post方法中得到一個錯誤,並且我會顯示一條錯誤消息(這會消失與按鈕),並且我給出如何將參數字符串說出錯(如何顯示字符串不是問題,問題是如何通過字符串)。管理多個qml文件
我將有一個加載程序元素,並且如果我不包含錯誤管理,則工作正常。 而我不希望qml中的C++對象(例如我的類Httppost)。 我QML代碼是這樣的:
Loader {
id: pageLoader // ID needed for so we can later delete the item
source: "AnimationSplash.qml"
focus: true
property bool valid: item !== null
anchors.horizontalCenter: parent.horizontalCenter
objectName: "switchPages"
}
Timer {
id: firstPhaseTimer
interval: 750
running: true
repeat: false
onTriggered:{
pageLoader.item.opacity=0;
pageLoader.source="SearchRecipient.qml"
}
}
Connections{
target:pageLoader.item
ignoreUnknownSignals: true
onPostIdClient: {
postClient(pageLoader.typeId, pageLoader.textIdClient)
}
onPostIdVent: {
postVent(pageLoader.textIdVent)
pageLoader.source="MainView.qml"
}
}
postIdClient和postIDVent從加載文件的信號,但任何人有一個suggerence如何變化ErrorScreen,如果我的管理錯誤的是C++。
我的C++構造函數代碼(是我加載main.qml文件)是這樣的:
QObject *mainObject;
QQuickView view;
view.setSource(QUrl::fromLocalFile("./ui/main.qml"));
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.show();
mainObject=view.rootObject();
QObject *switcher=mainObject->findChild<QObject*>("");
if(mainObject)
{
QObject::connect(mainObject, SIGNAL(postClient(QString,QString)), this, SLOT(postingClientData(QString,QString)),Qt::UniqueConnection);
QObject::connect(mainObject, SIGNAL(postVent(QString)), this, SLOT(postIdVent(QString)),Qt::UniqueConnection);
}
最後,如何讀取和設置的MainView的性質,如果我沒有從孩子的QObject訪問QQuickView(我用這個clang加載main.qml)
感謝您對標題的更正 – APRocha