title: Run an active window inside an PyQT5 GUI application
body: <p>I'm using PyQT5, and I want to run an external window inside an TabWidget, something similar <a href="https://stackoverflow.com/questions/41474647/run-a-foreign-exe-inside-%20a-python-gui-pyqt">to that</a>, but this example is for windows only, and i want to run in a linux (Ubuntu 14.04) os. I also find a similar problem in this <a href="https://stackoverflow.com/questions/53883386/how-can-i-embed-another-software-in-my-qt-window-in-linux/57084914#57084914">thread</a> but the answers didn't work. Also tried the solution <a href="https://stackoverflow.com/questions/57015932/how-to-attach-and-detach-an-external-app-with-pyqt5-or-dock-an-external-applicat">here</a> but didn't work either. Is possible to embed an terminal, like <a href="https://stackoverflow.com/questions/51975678/embedding-a-terminal-in-pyqt5">this code</a>, but i have no idea how to do the same with the RViz command. I have some code bellow, who uses <strong>wmctrl</strong> to pick the RViz (the application that i want to embed in my GUI) window ID, and try to put inside the "fromWinID()" class, but the window opens outside my app and also receive the error:</p>
  
  <pre><code>QXcbConnection: XCB error: 3 (BadWindow), sequence: 415, resource id: -1222189812, major code: 7 (ReparentWindow), minor code: 0
  QXcbConnection: XCB error: 3 (BadWindow), sequence: 460, resource id: -1222189812, major code: 7 (ReparentWindow), minor code: 0
  QXcbConnection: XCB error: 3 (BadWindow), sequence: 461, resource id: -1222189812, major code: 8 (MapWindow), minor code: 0
  QXcbConnection: XCB error: 3 (BadWindow), sequence: 463, resource id: -1222189812, major code: 18 (ChangeProperty), minor code: 0
  QXcbConnection: XCB error: 3 (BadWindow), sequence: 464, resource id: -1222189812, major code: 12 (ConfigureWindow), minor code: 0
  </code></pre>
  
  <p>Can someone help with that please?</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import sys
  from PyQt5 import QtCore, QtGui, QtWidgets
  import subprocess
  from subprocess import call, Popen, PIPE, check_output
  
  class Container(QtWidgets.QTabWidget):
      def __init__(self):
          QtWidgets.QTabWidget.__init__(self)
          rvizCommand = 'rviz'
          # Using Popen instead of Call to dont block the process
          subprocess.Popen(rvizCommand, stdout=PIPE,
                           stdin=PIPE, shell=True)
          # wmctrl to find the active hexadecimal   
          lookForID = "wmctrl -l | grep -i RViz | awk '{print $1}'"
          rvizID = subprocess.check_output(lookForID, shell=True)
          rvizID = str(rvizID.rstrip("\n"))
          print(rvizID)
          window = QtGui.QWindow.fromWinId(rvizID)
          container = QtWidgets.QWidget.createWindowContainer(window, self)               
          self.addTab(container, 'RViz')
  
  app = QtWidgets.QApplication(sys.argv)
  rviz = Container()
  rviz.show()
  sys.exit(app.exec_())
  </code></pre>