There are 2 solutions I can suggest for this.
The "easier" solution is to use a sheet for the message composing view instead of a tab. This can be opened from anywhere and you can then just pass the values into the sheet.
To use the tab requires some c++ code. I have recently had a similar issue where when a user taps on an element in another tab it needs to open the weather tab and show a 5 day forecast on the weather tab. However qml does not support opening a tab.
I made the following method in my c++:
ApplicationUI.cpp
void ApplicationUI::openTab(QString tabName) {
Tab *mTab = tabbedPane->findChild<Tab*>(tabName);
if (mTab == 0) {
qDebug() << "Error: unable to open tab " << tabName;
return;
}
tabbedPane->setActiveTab(mTab);
}
ApplicationUI.hpp
public:
Q_INVOKABLE void openTab(QString tabName);
Then you could do something like this:
Tab { // First tab
NavigationPane {
id: tmp_nav
Page {
ListView {
onTriggered: {
var pg = cmp_page.createObject();
messageNav.push(pg);
}
}
}
}
}
Tab { // Second Tab whose contents should be "cmp_page"
NavigationPane {
id: messageNav
}
}