def show_qt(qt_class, modal=False, onshow_event=None, force_style=False):
    """
    Shows and raise a pyqt window ensuring it's not duplicated
    (if it's duplicated then raise the old one).
    qt_class argument should be a class/subclass of QMainWindow, QDialog or any
    top-level widget.
    onshow_event provides a way to pass a function to execute before the window
    is showed on screen, it should be handy with modal windows.
    Returns the qt_class instance.
    """
    dialog = None
    window = anchor()
    # look for a previous instance
    for d in window.children():
        if isinstance(d, qt_class):
            dialog = d
    # if there's no previous instance then create a new one
    if dialog is None:
        dialog = qt_class(window)
    # stylize
    if force_style:
        set_style(dialog, not isinstance(dialog, QtGui.QMenu))
    # gc
    dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
    # show dialog
    pos = QtGui.QCursor.pos()
    dialog.move(pos.x(), pos.y())
    # execute callback
    if onshow_event:
        onshow_event(dialog)
    if modal:
        dialog.exec_()
    else:
        dialog.show()
        dialog.raise_()  # ensures dialog window is on top
    return dialog
Shows and raise a pyqt window ensuring it's not duplicated
    (if it's duplicated then raise the old one).
    qt_class argument should be a class/subclass of QMainWindow, QDialog or any
    top-level widget.
    onshow_event provides a way to pass a function to execute before the window
    is showed on screen, it should be handy with modal windows.
    Returns the qt_class instance.