将项目添加到 QLayout 时出错

Error in adding item to a QLayout

我正尝试在 QLayout(在 PyQT5 中)中添加一个项目,如下所示:

def add_parts_BC(self):
        """This adds a tab with part B and C"""

        BCVerticalLayout = QVBoxLayout()
        partB = PartB()
        partC = PartC()

        BCVerticalLayout.addWidget(PartB, QtCore.Qt.AlignTop)
        BCVerticalLayout.addWidget(PartC)

        # add the layout to the tabbed widget layout
        self.tabbedWidget.addTab(BCVerticalLayout, "Part B and C")

然后我收到以下错误消息:

BCVerticalLayout.addWidget(PartB, QtCore.Qt.AlignTop)
TypeError: QBoxLayout.addWidget(QWidget, int stretch=0, Qt.Alignment alignment=0): argument 1 has unexpected type 'PyQt5.QtCore.pyqtWrapperType'

不知道哪里做错了。有什么想法吗?

顺便说一句,PartA 和 PartB 看起来像这样:

class PartA(QWidget):
    def __init__(self):
        super().__init__()

    # more code here


class PartB(QWidget):
    def __init__(self):
        super().__init__()

    # more code here

我认为这是一个打字错误:

partB = PartB() #name of object with lower case p
partC = PartC()

BCVerticalLayout.addWidget(PartB, QtCore.Qt.AlignTop) #name of object with upper case p

所以应该是:

partB = PartB() 
partC = PartC()

BCVerticalLayout.addWidget(partB, QtCore.Qt.AlignTop)