I have 2 qml files:
1 is main.qml when user write his name and click go button send the name to main.cpp file and main.cpp send the name statment to
2 showName.qml and hide main.qml and open showName.qml
how to do that?
main.qml
Qt Code:
  1. import QtQuick 2.3
  2. import QtQuick.Window 2.2
  3. import QtQuick.Controls 1.2
  4.  
  5. Window {
  6. visible: true
  7.  
  8. TextField {
  9. id: aName
  10. placeholderText: qsTr("Enter your name")
  11. }
  12.  
  13. Button {
  14. id: go
  15. y: 50
  16. text: qsTr("Go")
  17. }
  18. }
To copy to clipboard, switch view to plain text mode 

showName.qml
Qt Code:
  1. import QtQuick 2.0
  2. import QtQuick.Window 2.2
  3. import QtQuick.Controls 1.2
  4.  
  5. Item {
  6. Text {
  7. id: aName
  8. text: qsTr( aName )// aName come from main.cpp
  9. font.pixelSize: 12
  10. }
  11.  
  12. }
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QGuiApplication>
  2. #include <QQmlApplicationEngine>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QGuiApplication app(argc, argv);
  7.  
  8. QQmlApplicationEngine engine;
  9. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  10. // i want here to get aName from main.cpp, send aName to showName.qml, hide main.qml and show showName.qml
  11. return app.exec();
  12. }
To copy to clipboard, switch view to plain text mode