本文整理汇总了Python中Qt.QtWidgets.QMainWindow方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QMainWindow方法的具体用法?Python QtWidgets.QMainWindow怎么用?Python QtWidgets.QMainWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Qt.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QMainWindow方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getMayaMainWindow
# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QMainWindow [as 别名]
def getMayaMainWindow():
if hasattr(Qt, "IsPySide2"):
if Qt.IsPySide2:
import shiboken2 as shiboken
else:
import shiboken
# Qt version less than 1.0.0
elif hasattr(Qt, "__version_info__"):
if Qt.__version_info__[0] >= 2:
import shiboken2 as shiboken
else:
import shiboken
else:
try:
import shiboken2 as shiboken
except:
import shiboken
return shiboken.wrapInstance(long(OpenMayaUI.MQtUtil_mainWindow()), QtWidgets.QMainWindow)
示例2: __init__
# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QMainWindow [as 别名]
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.parent = parent or self
self.nodegraph = NodeGraphWidget("main", parent=self.parent)
self.setCentralWidget(self.nodegraph)
self.resize(800, 600)
self.setWindowTitle("Node graph -")
# center = self.nodegraph.graph_view.sceneRect().center()
for i in range(0, 30):
prev_node = None
for j in range(0, 40):
node = self.nodegraph.graph_scene.create_node(
"random%d%d%d" % (i, j, random.randint(1, 1000)),
inputs=["in", "add"])
node.setPos(j * 350, i * 350)
if prev_node:
edge = self.nodegraph.graph_scene.create_edge(
prev_node._output, node._inputs[0])
prev_node = node
示例3: test_load_ui_customwidget
# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QMainWindow [as 别名]
def test_load_ui_customwidget():
"""Tests to see if loadUi loads a custom widget properly"""
import sys
from Qt import QtWidgets, QtCompat
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QMainWindow()
QtCompat.loadUi(self.ui_qcustomwidget, win)
# Ensure that the derived class was properly created
# and not the base class (in case of failure)
custom_class_name = getattr(win, "customwidget", None).__class__.__name__
excepted_class_name = CustomWidget(win).__class__.__name__
assert custom_class_name == excepted_class_name, \
"loadUi could not load custom widget to main window"
app.exit()
示例4: getMayaMainWindow
# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QMainWindow [as 别名]
def getMayaMainWindow():
"""
Since Maya is Qt, we can parent our UIs to it.
This means that we don't have to manage our UI and can leave it to Maya.
Returns:
QtWidgets.QMainWindow: The Maya MainWindow
"""
# We use the OpenMayaUI API to get a reference to Maya's MainWindow
win = omui.MQtUtil_mainWindow()
# Then we can use the wrapInstance method to convert it to something python can understand
# In this case, we're converting it to a QMainWindow
ptr = wrapInstance(long(win), QtWidgets.QMainWindow)
# Finally we return this to whoever wants it
return ptr
示例5: test_load_ui_mainwindow
# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QMainWindow [as 别名]
def test_load_ui_mainwindow():
"""Tests to see if the baseinstance loading loads a QMainWindow properly"""
import sys
from Qt import QtWidgets, QtCompat
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QMainWindow()
QtCompat.loadUi(self.ui_qmainwindow, win)
assert hasattr(win, 'lineEdit'), \
"loadUi could not load instance to main window"
app.exit()
示例6: test_load_ui_existingLayoutOnMainWindow
# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QMainWindow [as 别名]
def test_load_ui_existingLayoutOnMainWindow():
"""Tests to see if loading a ui onto a layout in a MainWindow works"""
import sys
from Qt import QtWidgets, QtCompat
msgs = 'QLayout: Attempting to add QLayout "" to QMainWindow ' \
'"", which already has a layout'
with ignoreQtMessageHandler([msgs]):
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QMainWindow()
QtWidgets.QComboBox(win)
QtWidgets.QHBoxLayout(win)
QtCompat.loadUi(self.ui_qmainwindow, win)
app.exit()
示例7: test
# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QMainWindow [as 别名]
def test():
"""QtCore is taken out of Qt.py via QtSiteConfig.py"""
# Expose this directory, and therefore QtSiteConfig, to Python
sys.path.insert(0, os.path.dirname(__file__))
try:
from Qt import QtCore
except ImportError:
print("Qt.QtCore was successfully removed by QtSiteConfig.py")
else:
raise ImportError(
"Qt.QtCore was importable, update_members was not "
"applied correctly."
)
# Suppress "Qt.QtCore" imported but unused warning
QtCore
# Test _misplaced_members is applied correctly
from Qt import QtGui
assert QtGui.QColorTest == QtGui.QColor, (
"QtGui.QColor was not mapped to QtGui.QColorTest"
)
# Test _compatibility_members is applied correctly
title = "Test Widget"
from Qt import QtWidgets, QtCompat
app = QtWidgets.QApplication(sys.argv)
wid = QtWidgets.QWidget()
wid.setWindowTitle(title)
# Verify that our simple remapping of QWidget.windowTitle works
assert QtCompat.QWidget.windowTitleTest(wid) == title, (
"Non-decorated function was added to QtCompat.QWidget"
)
# Verify that our decorated remapping of QWidget.windowTitle works
check = "Test: {}".format(title)
assert QtCompat.QWidget.windowTitleDecorator(wid) == check, (
"Decorated method was not added to QtCompat.QWidget"
)
# Verify that our decorated remapping of QMainWindow.windowTitle is
# different than the QWidget version.
win = QtWidgets.QMainWindow()
win.setWindowTitle(title)
check = "QMainWindow Test: {}".format(title)
assert QtCompat.QMainWindow.windowTitleDecorator(win) == check, (
"Decorated method was added to QtCompat.QMainWindow"
)
# Suppress "app" imported but unused warning
app