mottosso / Qt.py

Minimal Python 2 & 3 shim around all Qt bindings - PySide, PySide2, PyQt4 and PyQt5.
MIT License
920 stars 253 forks source link

Should there be a wrapper around sip/shiboken? #53

Closed fredrikaverpil closed 1 year ago

fredrikaverpil commented 8 years ago

Originally asked by Pierre Augeard:

What would be the wrapper around sip/shiboken?

For example:

ben-hearn-sb commented 7 years ago

@mottosso yes of course it was this snippet that did not work for me

from maya import mel
from Qt import QtWidgets

def getMayaStatusLine():
    window = {o.objectName(): o for o in QtGui.qApp.topLevelWidgets()}["MayaWindow"]
    gStatusLine = mel.eval('$temp=$gStatusLineForm')
    statusLine = window.findChild(QtGui.QWidget, gStatusLine)
    return statusLine
mottosso commented 7 years ago

Thanks Ben, here's a modified copy that works.

from maya import mel
from Qt import QtWidgets

def getMayaStatusLine():
    app = QtWidgets.QApplication.instance()
    window = {o.objectName(): o for o in app.topLevelWidgets()}["MayaWindow"]
    gStatusLine = mel.eval('$temp=$gStatusLineForm')
    statusLine = window.findChild(QtWidgets.QWidget, gStatusLine)
    return statusLine

statusLine = getMayaStatusLine()
statusLine.setStyleSheet('QWidget {background: "steelblue"}')

Changes:

  1. QtGui was not imported
  2. QWidget doesn't reside in QtGui
  3. qApp was deprecated
fredrikaverpil commented 7 years ago

I'm not sure if this affects any future feature of Qt.py, such as a wrapper around shiboken, but I figured I'd just mention it:

Hi all,

you know that the PySide(2) project is sub-divided into three main parts (no tools or examples):

pyside-setup, shiboken and pyside.

We have been fighting with this structure quite often. It is sometimes really hard to keep the repositories in sync when we have several open branches in the workings.

I know there are people who are using shiboken separately. They need to change their workflow a little bit, because they now need to checkout pyside and copy shiboken out of it.

If you see a problem with that, please contact us now. We will for sure find a solution together.

Please see more here at the PySide mailing list: http://lists.qt-project.org/pipermail/pyside/2017-May/002492.html

OEP commented 6 years ago

Hopefully this is the right issue, but I'm hearing from our developers it is occasionally required to use shiboken/shiboken2.isValid() in rare cases where Qt has cleaned up an underlying C++ object from underneath Python. I think we will work around by exposing it in our internal libraries. I'm not asking for it to be exposed by Qt.py, but just noting that here since I didn't see it discussed while researching.

mottosso commented 6 years ago

@oep It's better suited for a separate issue, I think. Since it's a missing member. If you pop one up, or better yet, submit a PR for it, I'm happy to see this included!

fredrikaverpil commented 1 year ago

Just doing some autumn cleaning...