小编Min*_*ina的帖子

模块“PyQt6.QtWidgets”没有属性“QDesktopWidget”

我尝试运行此代码,但它总是收到此 AttributeError,我搜索了很多网站但没有任何答案。

QtWidgets.QDesktopWidget().availableGeometry().center()
AttributeError: module 'PyQt6.QtWidgets' has no attribute 'QDesktopWidget'
Run Code Online (Sandbox Code Playgroud)

我的代码:

from PyQt6 import QtCore, QtGui, QtWidgets

class Ui_Form(object):
    def center(self):
        qr = Form.frameGeometry()
        cp = QtWidgets.QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())
Run Code Online (Sandbox Code Playgroud)

我正在使用 PyQt6 版本 6.1.0,Python 3.9.5

python pyqt python-3.x python-3.9 pyqt6

7
推荐指数
1
解决办法
6882
查看次数

标签 统计

pyqt ×1

pyqt6 ×1

python ×1

python-3.9 ×1

python-3.x ×1