这是错误还是功能?

发布于 2024-12-25 14:44:38 字数 1135 浏览 3 评论 0原文

这是一个测试脚本:

import sys
from PyQt4 import QtGui

class Form(QtGui.QDialog):

    def __init__(self, parent):
        QtGui.QDialog.__init__(self, parent)
        layout = QtGui.QFormLayout(self)
        for i in range(5):
            widget = QtGui.QLineEdit()
            widget.setObjectName('line_edit_%i' % i)
            layout.addRow(QtGui.QLabel('label_%i' % i), widget)
        self.setLayout(layout)


app = QtGui.QApplication(sys.argv)

def onFocusChanged(old, new):
    print('onFocusChanged: old = %s, new = %s' % (old and old.objectName() or None , new and new.objectName() or None))

app.focusChanged.connect(onFocusChanged)

mainWindow = QtGui.QMainWindow(None)
mdiArea = QtGui.QMdiArea()
mdiArea.setDocumentMode(True)
mainWindow.setCentralWidget(mdiArea)
subWindow = QtGui.QMdiSubWindow()
subWindow.setWidget(Form(None))
mdiArea.addSubWindow(subWindow)
mainWindow.show()

app.exec_()

问题是,当我不断双击子窗口标题以将其最大化并将其恢复回来时,焦点会切换到子窗口中的下一个小部件。

我制作了一个视频:http://www.youtube.com/watch?v=L26GqIBkQW8

这是一个错误吗?

Here is a test script:

import sys
from PyQt4 import QtGui

class Form(QtGui.QDialog):

    def __init__(self, parent):
        QtGui.QDialog.__init__(self, parent)
        layout = QtGui.QFormLayout(self)
        for i in range(5):
            widget = QtGui.QLineEdit()
            widget.setObjectName('line_edit_%i' % i)
            layout.addRow(QtGui.QLabel('label_%i' % i), widget)
        self.setLayout(layout)


app = QtGui.QApplication(sys.argv)

def onFocusChanged(old, new):
    print('onFocusChanged: old = %s, new = %s' % (old and old.objectName() or None , new and new.objectName() or None))

app.focusChanged.connect(onFocusChanged)

mainWindow = QtGui.QMainWindow(None)
mdiArea = QtGui.QMdiArea()
mdiArea.setDocumentMode(True)
mainWindow.setCentralWidget(mdiArea)
subWindow = QtGui.QMdiSubWindow()
subWindow.setWidget(Form(None))
mdiArea.addSubWindow(subWindow)
mainWindow.show()

app.exec_()

The issue is that when i double click constantly on subwindow title to maximize it and restore it back, the focus switches to the next widget in the subwindow.

I made a video: http://www.youtube.com/watch?v=L26GqIBkQW8

Is this a bug?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文