Skip to content

Commit f858768

Browse files
committed
Fix #133
1 parent b0f4158 commit f858768

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Qt.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,18 @@ def init():
239239
)
240240

241241
for binding in bindings:
242-
log("Trying %s" % binding.__name__[1:], verbose)
242+
log("Trying %s" % binding.__name__, verbose)
243243

244244
try:
245-
sys.modules[__name__] = binding()
245+
binding = binding()
246+
247+
sys.modules.update({
248+
__name__: binding,
249+
250+
# Fix #133, `from Qt.QtWidgets import QPushButton`
251+
__name__ + ".QtWidgets": binding.QtWidgets
252+
})
253+
246254
return
247255

248256
except ImportError as e:

tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ def test_vendoring():
159159
) == 0
160160

161161

162+
def test_import_from_qtwidgets():
163+
"""Fix #133, `from Qt.QtWidgets import XXX` works"""
164+
from Qt.QtWidgets import QPushButton
165+
assert QPushButton.__name__ == "QPushButton", QPushButton
166+
167+
162168
if binding("PyQt4"):
163169
def test_preferred_pyqt4():
164170
"""QT_PREFERRED_BINDING = PyQt4 properly forces the binding"""

0 commit comments

Comments
 (0)