本文整理汇总了Python中Qt.QtCompat.wrapInstance方法的典型用法代码示例。如果您正苦于以下问题:Python QtCompat.wrapInstance方法的具体用法?Python QtCompat.wrapInstance怎么用?Python QtCompat.wrapInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Qt.QtCompat
的用法示例。
在下文中一共展示了QtCompat.wrapInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_implicit_wrapInstance
# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import wrapInstance [as 别名]
def test_implicit_wrapInstance():
""".wrapInstance doesn't need the `base` argument"""
from Qt import QtCompat, QtWidgets
app = QtWidgets.QApplication(sys.argv)
try:
button = QtWidgets.QPushButton("Hello world")
button.setObjectName("MySpecialButton")
pointer = QtCompat.getCppPointer(button)
widget = QtCompat.wrapInstance(long(pointer))
assert isinstance(widget, QtWidgets.QWidget), widget
assert widget.objectName() == button.objectName()
if binding("PySide"):
assert widget != button
elif binding("PySide2") and _pyside2_commit_date() is None:
assert widget != button
elif binding("PySide2") and \
_pyside2_commit_date() <= datetime.datetime(
2017, 8, 25):
assert widget == button
else:
assert widget == button
finally:
app.exit()
示例2: test_wrapInstance
# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import wrapInstance [as 别名]
def test_wrapInstance():
""".wrapInstance and .getCppPointer is identical across all bindings"""
from Qt import QtCompat, QtWidgets
app = QtWidgets.QApplication(sys.argv)
try:
button = QtWidgets.QPushButton("Hello world")
button.setObjectName("MySpecialButton")
pointer = QtCompat.getCppPointer(button)
widget = QtCompat.wrapInstance(long(pointer),
QtWidgets.QWidget)
assert isinstance(widget, QtWidgets.QWidget), widget
assert widget.objectName() == button.objectName()
# IMPORTANT: this differs across sip and shiboken.
if binding("PySide") or binding("PySide2"):
assert widget != button
else:
assert widget == button
finally:
app.exit()