Returns the current `QApplication <http://doc.qt.nokia.com/qapplication.html>`_ instance or
    create one if it doesn't exists.

    :return: Application instance.
    :rtype: QApplication

def get_application_instance():
    """
    Returns the current `QApplication <http://doc.qt.nokia.com/qapplication.html>`_ instance or
    create one if it doesn't exists.

    :return: Application instance.
    :rtype: QApplication
    """

    instance = QApplication.instance()
    if not instance:
        instance = QApplication(sys.argv)
    return instance