title: Get root object from pyside2
body: <p>i have small application that i want to minimize to system tray, and i do have code that creates icon and minimizes it to system tray on push of a button, (on purpose i did not want to overwrite default close operation).</p>
  
  <p>How ever, i dont know how to get my root object from qml, so i am unable to perform any action, and when i would get it, what type would it be ?</p>
  
  <pre><code>app = QApplication(sys.argv)
  
  engine = QQmlApplicationEngine()
  manager = Manager()
  ctx = engine.rootContext()
  ctx.setContextProperty("Manager", manager)
  engine.load('main.qml')
  if not engine.rootObjects():
      sys.exit(-1)
  app.setWindowIcon(QtGui.QIcon('ico.png')) 
  sys.exit(app.exec_()) 
  
  
  
  class Manager(QObject):
   def __init__(self):
      QObject.__init__(self)
  
  
   self.tray_icon = QSystemTrayIcon(self)
  </code></pre>
  
  <p>now the following code i made to "work" on my application, even though is not working properly.</p>
  
  <pre><code>self.tray_icon.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))
      show_action = QAction("Show", self)
      quit_action = QAction("Exit", self)
      hide_action = QAction("Hide", self)
      show_action.triggered.connect(self.show)
      hide_action.triggered.connect(self.hide)
      quit_action.triggered.connect(qApp.quit)
      tray_menu = QMenu()
      tray_menu.addAction(show_action)
      tray_menu.addAction(hide_action)
      tray_menu.addAction(quit_action)
      self.tray_icon.setContextMenu(tray_menu)
      self.tray_icon.show()
  
  
  def minimize(self):
      self.hide()
      print("Test")
      _translate = QtCore.QCoreApplication.translate
      #self.hide()
      self.tray_icon.showMessage(
              "Tray Program",
              "Application was minimized to Tray",
              QSystemTrayIcon.Information,
              2000
          ) 
  </code></pre>
  
  <p>the only thing i did i changed </p>
  
  <pre><code>class Manager(QObject): to (QMainWindow)
  </code></pre>
  
  <p>and i could use this code, but instead manipulating my window, i got the completly new window, nonetheless i did get normal system tray icon and all menu items i  needed.</p>
  
  <p>So bottom line, how can i get reference of my root, and how can i use minimize to tray on it.</p>
  
  <p>root of my QML is normal ApplicationWindow.</p>
  
  <p>Just a small edit, i saw on some c++ examples they used to use ,</p>
  
  <pre><code>root = engine.rootObjects().at(0);
  </code></pre>
  
  <p>but this does not work anymore as i have seen. but i havent found any similar way.</p>