當前位置: 首頁>>代碼示例>>Python>>正文


Python QtWidgets.QMainWindow方法代碼示例

本文整理匯總了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) 
開發者ID:sol-ansano-kim,項目名稱:medic,代碼行數:23,代碼來源:functions.py

示例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 
開發者ID:dsideb,項目名稱:nodegraph-pyqt,代碼行數:23,代碼來源:main_perftest.py

示例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() 
開發者ID:mottosso,項目名稱:Qt.py,代碼行數:20,代碼來源:tests.py

示例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 
開發者ID:dgovil,項目名稱:PythonForMayaSamples,代碼行數:17,代碼來源:lightManager2016Below.py

示例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() 
開發者ID:mottosso,項目名稱:Qt.py,代碼行數:16,代碼來源:tests.py

示例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() 
開發者ID:mottosso,項目名稱:Qt.py,代碼行數:17,代碼來源:tests.py

示例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 
開發者ID:mottosso,項目名稱:Qt.py,代碼行數:56,代碼來源:main.py


注:本文中的Qt.QtWidgets.QMainWindow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。