1

I am trying to parent a QMainWindow to a non-qt application (the application may change). Any ideas on how to do this?

The qt window opens fine and i can interact with the python API in the applications however the qt window goes behind the application window if i click on the application. I could use Qt.WindowStaysOnTopHint flag but then it's on top of everything which isn't ideal.

Psuedo Example: If you were using an application (example Nuke) where the main application is also qt based you would use something like:

def _nuke_main_window():
    """Returns Nuke's main window"""
    for obj in QtWidgets.qApp.topLevelWidgets():
        if (obj.inherits('QMainWindow') and
                obj.metaObject().className() == 'Foundry::UI::DockMainWindow'):
            return obj
    else:
        raise RuntimeError('Could not find DockMainWindow instance')

wdg = myWidget(parent=_nuke_main_window())
wdg.show()

Maya and any other pyqt based window also would work similarly.

However if the application isnt qt based:

wdg = myWidget(parent=nonQtWindowQt_ised)
wdg.show()

where:

def nonQtWindowQt_ised():
    #return the application main window somehow maybe through python bindings like SIP?

Any examples (ideally) or useful direction would be much appreciated.

Using PyQt5, Python 3.5 and Linux.

Mafster
  • 107
  • 1
  • 3
  • 12
  • Your current question can be described as *too broad*, or *why is not this code working?* so if you do not give specific details is not suitable for SO. – eyllanesc Dec 30 '17 at 05:03
  • Sorry, updated. I thought for qt people it would make more sense perhaps. – Mafster Dec 30 '17 at 06:05
  • What information do you have about the non-Qt application? Its native window id? – G.M. Dec 30 '17 at 13:43
  • The only available qt api seems to be [setTransientParent](https://doc.qt.io/qt-5/qwindow.html#setTransientParent). However, it doesn't appear to be very reliable (see e.g. [QTBUG-55669](https://bugreports.qt.io/browse/QTBUG-55669)), and I couldn't get it to work on my linux system at all. What you need is some linux utility that can reliably set [WM_TRANSIENT_FOR](https://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR), but I don't know of any myself. – ekhumoro Dec 30 '17 at 19:07

0 Answers0