Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyQt6的Qt模块替代方案_Python_Pyqt_Pyqt6 - Fatal编程技术网

Python PyQt6的Qt模块替代方案

Python PyQt6的Qt模块替代方案,python,pyqt,pyqt6,Python,Pyqt,Pyqt6,我正在将我的应用程序从PyQt5迁移到PyQt6。据我所知,Qt6中的Qt模块已被移除。我有像“Qt.AlignCenter”、“Qt.toolbuttontextendericon”、“Qt.LeftToolBarArea”这样的东西,它们不再工作了。Qt6中是否有此功能的替代方案?Qt模块仅存在于PyQt5中(不在Qt5中),允许访问任何子模块的任何类或元素,例如: $ python >>> from PyQt5 import Qt >>> from Py

我正在将我的应用程序从PyQt5迁移到PyQt6。据我所知,Qt6中的Qt模块已被移除。我有像“Qt.AlignCenter”、“Qt.toolbuttontextendericon”、“Qt.LeftToolBarArea”这样的东西,它们不再工作了。Qt6中是否有此功能的替代方案?

Qt模块仅存在于PyQt5中(不在Qt5中),允许访问任何子模块的任何类或元素,例如:

$ python
>>> from PyQt5 import Qt
>>> from PyQt5 import QtWidgets
>>> assert Qt.QWidget == QtWidgets.QWidget
该模块与属于QtCore模块的Qt命名空间不同,因此如果要访问Qt.AlignCenter,则必须从QtCore导入Qt:

import sys
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QApplication, QLabel


def main():
    app = QApplication(sys.argv)
    w = QLabel()
    w.resize(640, 498)

    w.setAlignment(Qt.Alignment.AlignCenter)
    w.setText("Qt is awesome!!!")
    w.show()

    app.exec()


if __name__ == "__main__":
    main()
导入系统 从PyQt6.QtCore导入Qt 从PyQt6.qtwidts导入QApplication、QLabel def main(): app=QApplication(sys.argv) w=QLabel() w、 调整大小(640498) w、 setAlignment(Qt.Alignment.AlignCenter) w、 setText(“Qt太棒了!!!”) w、 show() app.exec() 如果名称=“\uuuuu main\uuuuuuuu”: main()
从PyQt6.QtCore导入Qt
从PyQt6.QtGui导入QIcon
从PyQt6.qtwidts导入QApplication、QMainWindow、QStyle、QToolBar
def main():
导入系统
app=QApplication(sys.argv)
toolbar=QToolBar()
toolbar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
icon=app.style().standardIcon(QStyle.StandardPixmap.SP_DesktopIcon)
工具栏.添加操作(图标,“桌面”)
w=QMainWindow()
w、 添加工具栏(Qt.toolbarea.lefttoolbarea,工具栏)
w、 show()
sys.exit(app.exec())
如果名称=“\uuuuu main\uuuuuuuu”:
main()
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QApplication, QMainWindow, QStyle, QToolBar


def main():
    import sys

    app = QApplication(sys.argv)

    toolbar = QToolBar()
    toolbar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)

    icon = app.style().standardIcon(QStyle.StandardPixmap.SP_DesktopIcon)
    toolbar.addAction(icon, "desktop")

    w = QMainWindow()
    w.addToolBar(Qt.ToolBarAreas.LeftToolBarArea, toolbar)
    w.show()

    sys.exit(app.exec())


if __name__ == "__main__":
    main()