We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pg.mkQApp generates warning
<!-- In the following, please describe your issue in detail! -->
<!-- If some of the sections do not apply, just remove them. -->

### Short description
`pg.mkQApp()` generates warning `QSettings::value: Empty key passed`

### Code to reproduce
```python
import pyqtgraph as pg
pg.mkQApp()
```

### Expected behavior
No output

### Real behavior
<!-- What happens? -->
Output to console:
```
QSettings::value: Empty key passed
QSettings::value: Empty key passed
```

### Tested environment(s)

 * PyQtGraph version: Latest commit from `develop` ( 6f4048596b080f71eaec544555159cb7c40c075f )
 * Qt Python binding: PyQt5 5.14.1 Qt 5.14.1
 * Python version: 3.8.2
 * NumPy version: 1.18.2
 * Operating system: Linux 5.5.7-1-MANJARO x86_64 19.0.2 Kyria
 * Installation method: Executed from source package

### Additional context
This is because `mkQApp` calls `QApplication([])`, which according to its documentation should never be called without arguments: See warning in https://doc.qt.io/qt-5/qapplication.html#QApplication

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pyqtgraph/Qt.py`
Content:
```
1 """
2 This module exists to smooth out some of the differences between PySide and PyQt4:
3 
4 * Automatically import either PyQt4 or PySide depending on availability
5 * Allow to import QtCore/QtGui pyqtgraph.Qt without specifying which Qt wrapper
6   you want to use.
7 * Declare QtCore.Signal, .Slot in PyQt4
8 * Declare loadUiType function for Pyside
9 
10 """
11 
12 import os, sys, re, time
13 
14 from .python2_3 import asUnicode
15 
16 PYSIDE = 'PySide'
17 PYSIDE2 = 'PySide2'
18 PYQT4 = 'PyQt4'
19 PYQT5 = 'PyQt5'
20 
21 QT_LIB = os.getenv('PYQTGRAPH_QT_LIB')
22 
23 ## Automatically determine which Qt package to use (unless specified by
24 ## environment variable).
25 ## This is done by first checking to see whether one of the libraries
26 ## is already imported. If not, then attempt to import PyQt4, then PySide.
27 if QT_LIB is None:
28     libOrder = [PYQT4, PYSIDE, PYQT5, PYSIDE2]
29 
30     for lib in libOrder:
31         if lib in sys.modules:
32             QT_LIB = lib
33             break
34 
35 if QT_LIB is None:
36     for lib in libOrder:
37         try:
38             __import__(lib)
39             QT_LIB = lib
40             break
41         except ImportError:
42             pass
43 
44 if QT_LIB is None:
45     raise Exception("PyQtGraph requires one of PyQt4, PyQt5, PySide or PySide2; none of these packages could be imported.")
46 
47 
48 class FailedImport(object):
49     """Used to defer ImportErrors until we are sure the module is needed.
50     """
51     def __init__(self, err):
52         self.err = err
53         
54     def __getattr__(self, attr):
55         raise self.err
56 
57 
58 def _isQObjectAlive(obj):
59     """An approximation of PyQt's isQObjectAlive().
60     """
61     try:
62         if hasattr(obj, 'parent'):
63             obj.parent()
64         elif hasattr(obj, 'parentItem'):
65             obj.parentItem()
66         else:
67             raise Exception("Cannot determine whether Qt object %s is still alive." % obj)
68     except RuntimeError:
69         return False
70     else:
71         return True
72 
73 
74 # Make a loadUiType function like PyQt has
75 
76 # Credit:
77 # http://stackoverflow.com/questions/4442286/python-code-genration-with-pyside-uic/14195313#14195313
78 
79 class _StringIO(object):
80     """Alternative to built-in StringIO needed to circumvent unicode/ascii issues"""
81     def __init__(self):
82         self.data = []
83     
84     def write(self, data):
85         self.data.append(data)
86         
87     def getvalue(self):
88         return ''.join(map(asUnicode, self.data)).encode('utf8')
89 
90     
91 def _loadUiType(uiFile):
92     """
93     PySide lacks a "loadUiType" command like PyQt4's, so we have to convert
94     the ui file to py code in-memory first and then execute it in a
95     special frame to retrieve the form_class.
96 
97     from stackoverflow: http://stackoverflow.com/a/14195313/3781327
98 
99     seems like this might also be a legitimate solution, but I'm not sure
100     how to make PyQt4 and pyside look the same...
101         http://stackoverflow.com/a/8717832
102     """
103 
104     if QT_LIB == "PYSIDE":
105         import pysideuic
106     else:
107         import pyside2uic as pysideuic
108     import xml.etree.ElementTree as xml
109 
110     parsed = xml.parse(uiFile)
111     widget_class = parsed.find('widget').get('class')
112     form_class = parsed.find('class').text
113     
114     with open(uiFile, 'r') as f:
115         o = _StringIO()
116         frame = {}
117 
118         pysideuic.compileUi(f, o, indent=0)
119         pyc = compile(o.getvalue(), '<string>', 'exec')
120         exec(pyc, frame)
121 
122         #Fetch the base_class and form class based on their type in the xml from designer
123         form_class = frame['Ui_%s'%form_class]
124         base_class = eval('QtGui.%s'%widget_class)
125 
126     return form_class, base_class
127 
128 
129 if QT_LIB == PYSIDE:
130     from PySide import QtGui, QtCore
131 
132     try:
133         from PySide import QtOpenGL
134     except ImportError as err:
135         QtOpenGL = FailedImport(err)
136     try:
137         from PySide import QtSvg
138     except ImportError as err:
139         QtSvg = FailedImport(err)
140 
141     try:
142         from PySide import QtTest
143     except ImportError as err:
144         QtTest = FailedImport(err)
145     
146     try:
147         from PySide import shiboken
148         isQObjectAlive = shiboken.isValid
149     except ImportError:
150         # use approximate version
151         isQObjectAlive = _isQObjectAlive
152     
153     import PySide
154     VERSION_INFO = 'PySide ' + PySide.__version__ + ' Qt ' + QtCore.__version__
155     
156 elif QT_LIB == PYQT4:
157     from PyQt4 import QtGui, QtCore, uic
158     try:
159         from PyQt4 import QtSvg
160     except ImportError as err:
161         QtSvg = FailedImport(err)
162     try:
163         from PyQt4 import QtOpenGL
164     except ImportError as err:
165         QtOpenGL = FailedImport(err)
166     try:
167         from PyQt4 import QtTest
168     except ImportError as err:
169         QtTest = FailedImport(err)
170 
171     VERSION_INFO = 'PyQt4 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR
172 
173 elif QT_LIB == PYQT5:
174     # We're using PyQt5 which has a different structure so we're going to use a shim to
175     # recreate the Qt4 structure for Qt5
176     from PyQt5 import QtGui, QtCore, QtWidgets, uic
177     
178     # PyQt5, starting in v5.5, calls qAbort when an exception is raised inside
179     # a slot. To maintain backward compatibility (and sanity for interactive
180     # users), we install a global exception hook to override this behavior.
181     ver = QtCore.PYQT_VERSION_STR.split('.')
182     if int(ver[1]) >= 5:
183         if sys.excepthook == sys.__excepthook__:
184             sys_excepthook = sys.excepthook
185             def pyqt5_qabort_override(*args, **kwds):
186                 return sys_excepthook(*args, **kwds)
187             sys.excepthook = pyqt5_qabort_override
188     
189     try:
190         from PyQt5 import QtSvg
191     except ImportError as err:
192         QtSvg = FailedImport(err)
193     try:
194         from PyQt5 import QtOpenGL
195     except ImportError as err:
196         QtOpenGL = FailedImport(err)
197     try:
198         from PyQt5 import QtTest
199         QtTest.QTest.qWaitForWindowShown = QtTest.QTest.qWaitForWindowExposed
200     except ImportError as err:
201         QtTest = FailedImport(err)
202 
203     VERSION_INFO = 'PyQt5 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR
204 
205 elif QT_LIB == PYSIDE2:
206     from PySide2 import QtGui, QtCore, QtWidgets
207     
208     try:
209         from PySide2 import QtSvg
210     except ImportError as err:
211         QtSvg = FailedImport(err)
212     try:
213         from PySide2 import QtOpenGL
214     except ImportError as err:
215         QtOpenGL = FailedImport(err)
216     try:
217         from PySide2 import QtTest
218         QtTest.QTest.qWaitForWindowShown = QtTest.QTest.qWaitForWindowExposed
219     except ImportError as err:
220         QtTest = FailedImport(err)
221 
222     try:
223         import shiboken2
224         isQObjectAlive = shiboken2.isValid
225     except ImportError:
226         # use approximate version
227         isQObjectAlive = _isQObjectAlive    
228     import PySide2
229     VERSION_INFO = 'PySide2 ' + PySide2.__version__ + ' Qt ' + QtCore.__version__
230 
231 else:
232     raise ValueError("Invalid Qt lib '%s'" % QT_LIB)
233 
234 
235 # common to PyQt5 and PySide2
236 if QT_LIB in [PYQT5, PYSIDE2]:
237     # We're using Qt5 which has a different structure so we're going to use a shim to
238     # recreate the Qt4 structure
239     
240     __QGraphicsItem_scale = QtWidgets.QGraphicsItem.scale
241 
242     def scale(self, *args):
243         if args:
244             sx, sy = args
245             tr = self.transform()
246             tr.scale(sx, sy)
247             self.setTransform(tr)
248         else:
249             return __QGraphicsItem_scale(self)
250 
251     QtWidgets.QGraphicsItem.scale = scale
252 
253     def rotate(self, angle):
254         tr = self.transform()
255         tr.rotate(angle)
256         self.setTransform(tr)
257     QtWidgets.QGraphicsItem.rotate = rotate
258 
259     def translate(self, dx, dy):
260         tr = self.transform()
261         tr.translate(dx, dy)
262         self.setTransform(tr)
263     QtWidgets.QGraphicsItem.translate = translate
264 
265     def setMargin(self, i):
266         self.setContentsMargins(i, i, i, i)
267     QtWidgets.QGridLayout.setMargin = setMargin
268 
269     def setResizeMode(self, *args):
270         self.setSectionResizeMode(*args)
271     QtWidgets.QHeaderView.setResizeMode = setResizeMode
272 
273     
274     QtGui.QApplication = QtWidgets.QApplication
275     QtGui.QGraphicsScene = QtWidgets.QGraphicsScene
276     QtGui.QGraphicsObject = QtWidgets.QGraphicsObject
277     QtGui.QGraphicsWidget = QtWidgets.QGraphicsWidget
278 
279     QtGui.QApplication.setGraphicsSystem = None
280     
281     # Import all QtWidgets objects into QtGui
282     for o in dir(QtWidgets):
283         if o.startswith('Q'):
284             setattr(QtGui, o, getattr(QtWidgets,o) )
285     
286 
287 # Common to PySide and PySide2
288 if QT_LIB in [PYSIDE, PYSIDE2]:
289     QtVersion = QtCore.__version__
290     loadUiType = _loadUiType
291         
292     # PySide does not implement qWait
293     if not isinstance(QtTest, FailedImport):
294         if not hasattr(QtTest.QTest, 'qWait'):
295             @staticmethod
296             def qWait(msec):
297                 start = time.time()
298                 QtGui.QApplication.processEvents()
299                 while time.time() < start + msec * 0.001:
300                     QtGui.QApplication.processEvents()
301             QtTest.QTest.qWait = qWait
302 
303 
304 # Common to PyQt4 and 5
305 if QT_LIB in [PYQT4, PYQT5]:
306     QtVersion = QtCore.QT_VERSION_STR
307     
308     import sip
309     def isQObjectAlive(obj):
310         return not sip.isdeleted(obj)
311     
312     loadUiType = uic.loadUiType
313 
314     QtCore.Signal = QtCore.pyqtSignal
315     
316 
317 # USE_XXX variables are deprecated
318 USE_PYSIDE = QT_LIB == PYSIDE
319 USE_PYQT4 = QT_LIB == PYQT4
320 USE_PYQT5 = QT_LIB == PYQT5
321 
322     
323 ## Make sure we have Qt >= 4.7
324 versionReq = [4, 7]
325 m = re.match(r'(\d+)\.(\d+).*', QtVersion)
326 if m is not None and list(map(int, m.groups())) < versionReq:
327     print(list(map(int, m.groups())))
328     raise Exception('pyqtgraph requires Qt version >= %d.%d  (your version is %s)' % (versionReq[0], versionReq[1], QtVersion))
329 
330 
331 QAPP = None
332 def mkQApp():
333     global QAPP    
334     QAPP = QtGui.QApplication.instance()
335     if QAPP is None:
336         QAPP = QtGui.QApplication([])
337     return QAPP
338
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py
--- a/pyqtgraph/Qt.py
+++ b/pyqtgraph/Qt.py
@@ -329,9 +329,18 @@
 
 
 QAPP = None
-def mkQApp():
-    global QAPP    
+def mkQApp(name="pyqtgraph", qt_args=[]):
+    """
+    Creates new QApplication or returns current instance if existing.
+    
+    ==============  =================================================================================
+    **Arguments:**
+    name            Application name, passed to Qt
+    qt_args         Array of command line arguments passed to Qt
+    ==============  =================================================================================
+    """
+    global QAPP
     QAPP = QtGui.QApplication.instance()
     if QAPP is None:
-        QAPP = QtGui.QApplication([])
+        QAPP = QtGui.QApplication([name] + qt_args)
     return QAPP

{"golden_diff": "diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py\n--- a/pyqtgraph/Qt.py\n+++ b/pyqtgraph/Qt.py\n@@ -329,9 +329,18 @@\n \n \n QAPP = None\n-def mkQApp():\n-    global QAPP    \n+def mkQApp(name=\"pyqtgraph\", qt_args=[]):\n+    \"\"\"\n+    Creates new QApplication or returns current instance if existing.\n+    \n+    ==============  =================================================================================\n+    **Arguments:**\n+    name            Application name, passed to Qt\n+    qt_args         Array of command line arguments passed to Qt\n+    ==============  =================================================================================\n+    \"\"\"\n+    global QAPP\n     QAPP = QtGui.QApplication.instance()\n     if QAPP is None:\n-        QAPP = QtGui.QApplication([])\n+        QAPP = QtGui.QApplication([name] + qt_args)\n     return QAPP\n", "issue": "pg.mkQApp generates warning\n<!-- In the following, please describe your issue in detail! -->\r\n<!-- If some of the sections do not apply, just remove them. -->\r\n\r\n### Short description\r\n`pg.mkQApp()` generates warning `QSettings::value: Empty key passed`\r\n\r\n### Code to reproduce\r\n```python\r\nimport pyqtgraph as pg\r\npg.mkQApp()\r\n```\r\n\r\n### Expected behavior\r\nNo output\r\n\r\n### Real behavior\r\n<!-- What happens? -->\r\nOutput to console:\r\n```\r\nQSettings::value: Empty key passed\r\nQSettings::value: Empty key passed\r\n```\r\n\r\n### Tested environment(s)\r\n\r\n * PyQtGraph version: Latest commit from `develop` ( 6f4048596b080f71eaec544555159cb7c40c075f )\r\n * Qt Python binding: PyQt5 5.14.1 Qt 5.14.1\r\n * Python version: 3.8.2\r\n * NumPy version: 1.18.2\r\n * Operating system: Linux 5.5.7-1-MANJARO x86_64 19.0.2 Kyria\r\n * Installation method: Executed from source package\r\n\r\n### Additional context\r\nThis is because `mkQApp` calls `QApplication([])`, which according to its documentation should never be called without arguments: See warning in https://doc.qt.io/qt-5/qapplication.html#QApplication\n", "before_files": [{"content": "\"\"\"\nThis module exists to smooth out some of the differences between PySide and PyQt4:\n\n* Automatically import either PyQt4 or PySide depending on availability\n* Allow to import QtCore/QtGui pyqtgraph.Qt without specifying which Qt wrapper\n  you want to use.\n* Declare QtCore.Signal, .Slot in PyQt4\n* Declare loadUiType function for Pyside\n\n\"\"\"\n\nimport os, sys, re, time\n\nfrom .python2_3 import asUnicode\n\nPYSIDE = 'PySide'\nPYSIDE2 = 'PySide2'\nPYQT4 = 'PyQt4'\nPYQT5 = 'PyQt5'\n\nQT_LIB = os.getenv('PYQTGRAPH_QT_LIB')\n\n## Automatically determine which Qt package to use (unless specified by\n## environment variable).\n## This is done by first checking to see whether one of the libraries\n## is already imported. If not, then attempt to import PyQt4, then PySide.\nif QT_LIB is None:\n    libOrder = [PYQT4, PYSIDE, PYQT5, PYSIDE2]\n\n    for lib in libOrder:\n        if lib in sys.modules:\n            QT_LIB = lib\n            break\n\nif QT_LIB is None:\n    for lib in libOrder:\n        try:\n            __import__(lib)\n            QT_LIB = lib\n            break\n        except ImportError:\n            pass\n\nif QT_LIB is None:\n    raise Exception(\"PyQtGraph requires one of PyQt4, PyQt5, PySide or PySide2; none of these packages could be imported.\")\n\n\nclass FailedImport(object):\n    \"\"\"Used to defer ImportErrors until we are sure the module is needed.\n    \"\"\"\n    def __init__(self, err):\n        self.err = err\n        \n    def __getattr__(self, attr):\n        raise self.err\n\n\ndef _isQObjectAlive(obj):\n    \"\"\"An approximation of PyQt's isQObjectAlive().\n    \"\"\"\n    try:\n        if hasattr(obj, 'parent'):\n            obj.parent()\n        elif hasattr(obj, 'parentItem'):\n            obj.parentItem()\n        else:\n            raise Exception(\"Cannot determine whether Qt object %s is still alive.\" % obj)\n    except RuntimeError:\n        return False\n    else:\n        return True\n\n\n# Make a loadUiType function like PyQt has\n\n# Credit:\n# http://stackoverflow.com/questions/4442286/python-code-genration-with-pyside-uic/14195313#14195313\n\nclass _StringIO(object):\n    \"\"\"Alternative to built-in StringIO needed to circumvent unicode/ascii issues\"\"\"\n    def __init__(self):\n        self.data = []\n    \n    def write(self, data):\n        self.data.append(data)\n        \n    def getvalue(self):\n        return ''.join(map(asUnicode, self.data)).encode('utf8')\n\n    \ndef _loadUiType(uiFile):\n    \"\"\"\n    PySide lacks a \"loadUiType\" command like PyQt4's, so we have to convert\n    the ui file to py code in-memory first and then execute it in a\n    special frame to retrieve the form_class.\n\n    from stackoverflow: http://stackoverflow.com/a/14195313/3781327\n\n    seems like this might also be a legitimate solution, but I'm not sure\n    how to make PyQt4 and pyside look the same...\n        http://stackoverflow.com/a/8717832\n    \"\"\"\n\n    if QT_LIB == \"PYSIDE\":\n        import pysideuic\n    else:\n        import pyside2uic as pysideuic\n    import xml.etree.ElementTree as xml\n\n    parsed = xml.parse(uiFile)\n    widget_class = parsed.find('widget').get('class')\n    form_class = parsed.find('class').text\n    \n    with open(uiFile, 'r') as f:\n        o = _StringIO()\n        frame = {}\n\n        pysideuic.compileUi(f, o, indent=0)\n        pyc = compile(o.getvalue(), '<string>', 'exec')\n        exec(pyc, frame)\n\n        #Fetch the base_class and form class based on their type in the xml from designer\n        form_class = frame['Ui_%s'%form_class]\n        base_class = eval('QtGui.%s'%widget_class)\n\n    return form_class, base_class\n\n\nif QT_LIB == PYSIDE:\n    from PySide import QtGui, QtCore\n\n    try:\n        from PySide import QtOpenGL\n    except ImportError as err:\n        QtOpenGL = FailedImport(err)\n    try:\n        from PySide import QtSvg\n    except ImportError as err:\n        QtSvg = FailedImport(err)\n\n    try:\n        from PySide import QtTest\n    except ImportError as err:\n        QtTest = FailedImport(err)\n    \n    try:\n        from PySide import shiboken\n        isQObjectAlive = shiboken.isValid\n    except ImportError:\n        # use approximate version\n        isQObjectAlive = _isQObjectAlive\n    \n    import PySide\n    VERSION_INFO = 'PySide ' + PySide.__version__ + ' Qt ' + QtCore.__version__\n    \nelif QT_LIB == PYQT4:\n    from PyQt4 import QtGui, QtCore, uic\n    try:\n        from PyQt4 import QtSvg\n    except ImportError as err:\n        QtSvg = FailedImport(err)\n    try:\n        from PyQt4 import QtOpenGL\n    except ImportError as err:\n        QtOpenGL = FailedImport(err)\n    try:\n        from PyQt4 import QtTest\n    except ImportError as err:\n        QtTest = FailedImport(err)\n\n    VERSION_INFO = 'PyQt4 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR\n\nelif QT_LIB == PYQT5:\n    # We're using PyQt5 which has a different structure so we're going to use a shim to\n    # recreate the Qt4 structure for Qt5\n    from PyQt5 import QtGui, QtCore, QtWidgets, uic\n    \n    # PyQt5, starting in v5.5, calls qAbort when an exception is raised inside\n    # a slot. To maintain backward compatibility (and sanity for interactive\n    # users), we install a global exception hook to override this behavior.\n    ver = QtCore.PYQT_VERSION_STR.split('.')\n    if int(ver[1]) >= 5:\n        if sys.excepthook == sys.__excepthook__:\n            sys_excepthook = sys.excepthook\n            def pyqt5_qabort_override(*args, **kwds):\n                return sys_excepthook(*args, **kwds)\n            sys.excepthook = pyqt5_qabort_override\n    \n    try:\n        from PyQt5 import QtSvg\n    except ImportError as err:\n        QtSvg = FailedImport(err)\n    try:\n        from PyQt5 import QtOpenGL\n    except ImportError as err:\n        QtOpenGL = FailedImport(err)\n    try:\n        from PyQt5 import QtTest\n        QtTest.QTest.qWaitForWindowShown = QtTest.QTest.qWaitForWindowExposed\n    except ImportError as err:\n        QtTest = FailedImport(err)\n\n    VERSION_INFO = 'PyQt5 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR\n\nelif QT_LIB == PYSIDE2:\n    from PySide2 import QtGui, QtCore, QtWidgets\n    \n    try:\n        from PySide2 import QtSvg\n    except ImportError as err:\n        QtSvg = FailedImport(err)\n    try:\n        from PySide2 import QtOpenGL\n    except ImportError as err:\n        QtOpenGL = FailedImport(err)\n    try:\n        from PySide2 import QtTest\n        QtTest.QTest.qWaitForWindowShown = QtTest.QTest.qWaitForWindowExposed\n    except ImportError as err:\n        QtTest = FailedImport(err)\n\n    try:\n        import shiboken2\n        isQObjectAlive = shiboken2.isValid\n    except ImportError:\n        # use approximate version\n        isQObjectAlive = _isQObjectAlive    \n    import PySide2\n    VERSION_INFO = 'PySide2 ' + PySide2.__version__ + ' Qt ' + QtCore.__version__\n\nelse:\n    raise ValueError(\"Invalid Qt lib '%s'\" % QT_LIB)\n\n\n# common to PyQt5 and PySide2\nif QT_LIB in [PYQT5, PYSIDE2]:\n    # We're using Qt5 which has a different structure so we're going to use a shim to\n    # recreate the Qt4 structure\n    \n    __QGraphicsItem_scale = QtWidgets.QGraphicsItem.scale\n\n    def scale(self, *args):\n        if args:\n            sx, sy = args\n            tr = self.transform()\n            tr.scale(sx, sy)\n            self.setTransform(tr)\n        else:\n            return __QGraphicsItem_scale(self)\n\n    QtWidgets.QGraphicsItem.scale = scale\n\n    def rotate(self, angle):\n        tr = self.transform()\n        tr.rotate(angle)\n        self.setTransform(tr)\n    QtWidgets.QGraphicsItem.rotate = rotate\n\n    def translate(self, dx, dy):\n        tr = self.transform()\n        tr.translate(dx, dy)\n        self.setTransform(tr)\n    QtWidgets.QGraphicsItem.translate = translate\n\n    def setMargin(self, i):\n        self.setContentsMargins(i, i, i, i)\n    QtWidgets.QGridLayout.setMargin = setMargin\n\n    def setResizeMode(self, *args):\n        self.setSectionResizeMode(*args)\n    QtWidgets.QHeaderView.setResizeMode = setResizeMode\n\n    \n    QtGui.QApplication = QtWidgets.QApplication\n    QtGui.QGraphicsScene = QtWidgets.QGraphicsScene\n    QtGui.QGraphicsObject = QtWidgets.QGraphicsObject\n    QtGui.QGraphicsWidget = QtWidgets.QGraphicsWidget\n\n    QtGui.QApplication.setGraphicsSystem = None\n    \n    # Import all QtWidgets objects into QtGui\n    for o in dir(QtWidgets):\n        if o.startswith('Q'):\n            setattr(QtGui, o, getattr(QtWidgets,o) )\n    \n\n# Common to PySide and PySide2\nif QT_LIB in [PYSIDE, PYSIDE2]:\n    QtVersion = QtCore.__version__\n    loadUiType = _loadUiType\n        \n    # PySide does not implement qWait\n    if not isinstance(QtTest, FailedImport):\n        if not hasattr(QtTest.QTest, 'qWait'):\n            @staticmethod\n            def qWait(msec):\n                start = time.time()\n                QtGui.QApplication.processEvents()\n                while time.time() < start + msec * 0.001:\n                    QtGui.QApplication.processEvents()\n            QtTest.QTest.qWait = qWait\n\n\n# Common to PyQt4 and 5\nif QT_LIB in [PYQT4, PYQT5]:\n    QtVersion = QtCore.QT_VERSION_STR\n    \n    import sip\n    def isQObjectAlive(obj):\n        return not sip.isdeleted(obj)\n    \n    loadUiType = uic.loadUiType\n\n    QtCore.Signal = QtCore.pyqtSignal\n    \n\n# USE_XXX variables are deprecated\nUSE_PYSIDE = QT_LIB == PYSIDE\nUSE_PYQT4 = QT_LIB == PYQT4\nUSE_PYQT5 = QT_LIB == PYQT5\n\n    \n## Make sure we have Qt >= 4.7\nversionReq = [4, 7]\nm = re.match(r'(\\d+)\\.(\\d+).*', QtVersion)\nif m is not None and list(map(int, m.groups())) < versionReq:\n    print(list(map(int, m.groups())))\n    raise Exception('pyqtgraph requires Qt version >= %d.%d  (your version is %s)' % (versionReq[0], versionReq[1], QtVersion))\n\n\nQAPP = None\ndef mkQApp():\n    global QAPP    \n    QAPP = QtGui.QApplication.instance()\n    if QAPP is None:\n        QAPP = QtGui.QApplication([])\n    return QAPP\n", "path": "pyqtgraph/Qt.py"}], "after_files": [{"content": "\"\"\"\nThis module exists to smooth out some of the differences between PySide and PyQt4:\n\n* Automatically import either PyQt4 or PySide depending on availability\n* Allow to import QtCore/QtGui pyqtgraph.Qt without specifying which Qt wrapper\n  you want to use.\n* Declare QtCore.Signal, .Slot in PyQt4\n* Declare loadUiType function for Pyside\n\n\"\"\"\n\nimport os, sys, re, time\n\nfrom .python2_3 import asUnicode\n\nPYSIDE = 'PySide'\nPYSIDE2 = 'PySide2'\nPYQT4 = 'PyQt4'\nPYQT5 = 'PyQt5'\n\nQT_LIB = os.getenv('PYQTGRAPH_QT_LIB')\n\n## Automatically determine which Qt package to use (unless specified by\n## environment variable).\n## This is done by first checking to see whether one of the libraries\n## is already imported. If not, then attempt to import PyQt4, then PySide.\nif QT_LIB is None:\n    libOrder = [PYQT4, PYSIDE, PYQT5, PYSIDE2]\n\n    for lib in libOrder:\n        if lib in sys.modules:\n            QT_LIB = lib\n            break\n\nif QT_LIB is None:\n    for lib in libOrder:\n        try:\n            __import__(lib)\n            QT_LIB = lib\n            break\n        except ImportError:\n            pass\n\nif QT_LIB is None:\n    raise Exception(\"PyQtGraph requires one of PyQt4, PyQt5, PySide or PySide2; none of these packages could be imported.\")\n\n\nclass FailedImport(object):\n    \"\"\"Used to defer ImportErrors until we are sure the module is needed.\n    \"\"\"\n    def __init__(self, err):\n        self.err = err\n        \n    def __getattr__(self, attr):\n        raise self.err\n\n\ndef _isQObjectAlive(obj):\n    \"\"\"An approximation of PyQt's isQObjectAlive().\n    \"\"\"\n    try:\n        if hasattr(obj, 'parent'):\n            obj.parent()\n        elif hasattr(obj, 'parentItem'):\n            obj.parentItem()\n        else:\n            raise Exception(\"Cannot determine whether Qt object %s is still alive.\" % obj)\n    except RuntimeError:\n        return False\n    else:\n        return True\n\n\n# Make a loadUiType function like PyQt has\n\n# Credit:\n# http://stackoverflow.com/questions/4442286/python-code-genration-with-pyside-uic/14195313#14195313\n\nclass _StringIO(object):\n    \"\"\"Alternative to built-in StringIO needed to circumvent unicode/ascii issues\"\"\"\n    def __init__(self):\n        self.data = []\n    \n    def write(self, data):\n        self.data.append(data)\n        \n    def getvalue(self):\n        return ''.join(map(asUnicode, self.data)).encode('utf8')\n\n    \ndef _loadUiType(uiFile):\n    \"\"\"\n    PySide lacks a \"loadUiType\" command like PyQt4's, so we have to convert\n    the ui file to py code in-memory first and then execute it in a\n    special frame to retrieve the form_class.\n\n    from stackoverflow: http://stackoverflow.com/a/14195313/3781327\n\n    seems like this might also be a legitimate solution, but I'm not sure\n    how to make PyQt4 and pyside look the same...\n        http://stackoverflow.com/a/8717832\n    \"\"\"\n\n    if QT_LIB == \"PYSIDE\":\n        import pysideuic\n    else:\n        import pyside2uic as pysideuic\n    import xml.etree.ElementTree as xml\n\n    parsed = xml.parse(uiFile)\n    widget_class = parsed.find('widget').get('class')\n    form_class = parsed.find('class').text\n    \n    with open(uiFile, 'r') as f:\n        o = _StringIO()\n        frame = {}\n\n        pysideuic.compileUi(f, o, indent=0)\n        pyc = compile(o.getvalue(), '<string>', 'exec')\n        exec(pyc, frame)\n\n        #Fetch the base_class and form class based on their type in the xml from designer\n        form_class = frame['Ui_%s'%form_class]\n        base_class = eval('QtGui.%s'%widget_class)\n\n    return form_class, base_class\n\n\nif QT_LIB == PYSIDE:\n    from PySide import QtGui, QtCore\n\n    try:\n        from PySide import QtOpenGL\n    except ImportError as err:\n        QtOpenGL = FailedImport(err)\n    try:\n        from PySide import QtSvg\n    except ImportError as err:\n        QtSvg = FailedImport(err)\n\n    try:\n        from PySide import QtTest\n    except ImportError as err:\n        QtTest = FailedImport(err)\n    \n    try:\n        from PySide import shiboken\n        isQObjectAlive = shiboken.isValid\n    except ImportError:\n        # use approximate version\n        isQObjectAlive = _isQObjectAlive\n    \n    import PySide\n    VERSION_INFO = 'PySide ' + PySide.__version__ + ' Qt ' + QtCore.__version__\n    \nelif QT_LIB == PYQT4:\n    from PyQt4 import QtGui, QtCore, uic\n    try:\n        from PyQt4 import QtSvg\n    except ImportError as err:\n        QtSvg = FailedImport(err)\n    try:\n        from PyQt4 import QtOpenGL\n    except ImportError as err:\n        QtOpenGL = FailedImport(err)\n    try:\n        from PyQt4 import QtTest\n    except ImportError as err:\n        QtTest = FailedImport(err)\n\n    VERSION_INFO = 'PyQt4 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR\n\nelif QT_LIB == PYQT5:\n    # We're using PyQt5 which has a different structure so we're going to use a shim to\n    # recreate the Qt4 structure for Qt5\n    from PyQt5 import QtGui, QtCore, QtWidgets, uic\n    \n    # PyQt5, starting in v5.5, calls qAbort when an exception is raised inside\n    # a slot. To maintain backward compatibility (and sanity for interactive\n    # users), we install a global exception hook to override this behavior.\n    ver = QtCore.PYQT_VERSION_STR.split('.')\n    if int(ver[1]) >= 5:\n        if sys.excepthook == sys.__excepthook__:\n            sys_excepthook = sys.excepthook\n            def pyqt5_qabort_override(*args, **kwds):\n                return sys_excepthook(*args, **kwds)\n            sys.excepthook = pyqt5_qabort_override\n    \n    try:\n        from PyQt5 import QtSvg\n    except ImportError as err:\n        QtSvg = FailedImport(err)\n    try:\n        from PyQt5 import QtOpenGL\n    except ImportError as err:\n        QtOpenGL = FailedImport(err)\n    try:\n        from PyQt5 import QtTest\n        QtTest.QTest.qWaitForWindowShown = QtTest.QTest.qWaitForWindowExposed\n    except ImportError as err:\n        QtTest = FailedImport(err)\n\n    VERSION_INFO = 'PyQt5 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR\n\nelif QT_LIB == PYSIDE2:\n    from PySide2 import QtGui, QtCore, QtWidgets\n    \n    try:\n        from PySide2 import QtSvg\n    except ImportError as err:\n        QtSvg = FailedImport(err)\n    try:\n        from PySide2 import QtOpenGL\n    except ImportError as err:\n        QtOpenGL = FailedImport(err)\n    try:\n        from PySide2 import QtTest\n        QtTest.QTest.qWaitForWindowShown = QtTest.QTest.qWaitForWindowExposed\n    except ImportError as err:\n        QtTest = FailedImport(err)\n\n    try:\n        import shiboken2\n        isQObjectAlive = shiboken2.isValid\n    except ImportError:\n        # use approximate version\n        isQObjectAlive = _isQObjectAlive    \n    import PySide2\n    VERSION_INFO = 'PySide2 ' + PySide2.__version__ + ' Qt ' + QtCore.__version__\n\nelse:\n    raise ValueError(\"Invalid Qt lib '%s'\" % QT_LIB)\n\n\n# common to PyQt5 and PySide2\nif QT_LIB in [PYQT5, PYSIDE2]:\n    # We're using Qt5 which has a different structure so we're going to use a shim to\n    # recreate the Qt4 structure\n    \n    __QGraphicsItem_scale = QtWidgets.QGraphicsItem.scale\n\n    def scale(self, *args):\n        if args:\n            sx, sy = args\n            tr = self.transform()\n            tr.scale(sx, sy)\n            self.setTransform(tr)\n        else:\n            return __QGraphicsItem_scale(self)\n\n    QtWidgets.QGraphicsItem.scale = scale\n\n    def rotate(self, angle):\n        tr = self.transform()\n        tr.rotate(angle)\n        self.setTransform(tr)\n    QtWidgets.QGraphicsItem.rotate = rotate\n\n    def translate(self, dx, dy):\n        tr = self.transform()\n        tr.translate(dx, dy)\n        self.setTransform(tr)\n    QtWidgets.QGraphicsItem.translate = translate\n\n    def setMargin(self, i):\n        self.setContentsMargins(i, i, i, i)\n    QtWidgets.QGridLayout.setMargin = setMargin\n\n    def setResizeMode(self, *args):\n        self.setSectionResizeMode(*args)\n    QtWidgets.QHeaderView.setResizeMode = setResizeMode\n\n    \n    QtGui.QApplication = QtWidgets.QApplication\n    QtGui.QGraphicsScene = QtWidgets.QGraphicsScene\n    QtGui.QGraphicsObject = QtWidgets.QGraphicsObject\n    QtGui.QGraphicsWidget = QtWidgets.QGraphicsWidget\n\n    QtGui.QApplication.setGraphicsSystem = None\n    \n    # Import all QtWidgets objects into QtGui\n    for o in dir(QtWidgets):\n        if o.startswith('Q'):\n            setattr(QtGui, o, getattr(QtWidgets,o) )\n    \n\n# Common to PySide and PySide2\nif QT_LIB in [PYSIDE, PYSIDE2]:\n    QtVersion = QtCore.__version__\n    loadUiType = _loadUiType\n        \n    # PySide does not implement qWait\n    if not isinstance(QtTest, FailedImport):\n        if not hasattr(QtTest.QTest, 'qWait'):\n            @staticmethod\n            def qWait(msec):\n                start = time.time()\n                QtGui.QApplication.processEvents()\n                while time.time() < start + msec * 0.001:\n                    QtGui.QApplication.processEvents()\n            QtTest.QTest.qWait = qWait\n\n\n# Common to PyQt4 and 5\nif QT_LIB in [PYQT4, PYQT5]:\n    QtVersion = QtCore.QT_VERSION_STR\n    \n    import sip\n    def isQObjectAlive(obj):\n        return not sip.isdeleted(obj)\n    \n    loadUiType = uic.loadUiType\n\n    QtCore.Signal = QtCore.pyqtSignal\n    \n\n# USE_XXX variables are deprecated\nUSE_PYSIDE = QT_LIB == PYSIDE\nUSE_PYQT4 = QT_LIB == PYQT4\nUSE_PYQT5 = QT_LIB == PYQT5\n\n    \n## Make sure we have Qt >= 4.7\nversionReq = [4, 7]\nm = re.match(r'(\\d+)\\.(\\d+).*', QtVersion)\nif m is not None and list(map(int, m.groups())) < versionReq:\n    print(list(map(int, m.groups())))\n    raise Exception('pyqtgraph requires Qt version >= %d.%d  (your version is %s)' % (versionReq[0], versionReq[1], QtVersion))\n\n\nQAPP = None\ndef mkQApp(name=\"pyqtgraph\", qt_args=[]):\n    \"\"\"\n    Creates new QApplication or returns current instance if existing.\n    \n    ==============  =================================================================================\n    **Arguments:**\n    name            Application name, passed to Qt\n    qt_args         Array of command line arguments passed to Qt\n    ==============  =================================================================================\n    \"\"\"\n    global QAPP\n    QAPP = QtGui.QApplication.instance()\n    if QAPP is None:\n        QAPP = QtGui.QApplication([name] + qt_args)\n    return QAPP\n", "path": "pyqtgraph/Qt.py"}]}