QTDesigner generated code is not working without change when design used other design

I designed a QWidget (main) having a QVBoxLayout using qtdesigner.
Adding an other designed Widget (custom) as user defined Placeholder into that QVBoxLayout and using pyuic6 will produce code that does not work.

The generated code posts:

addWidget(self, a0: Optional[QWidget], stretch: int = 0, alignment: Qt.AlignmentFlag = Qt.Alignment()): argument 1 has unexpected type 'widget_custom'

the generated codeline is:
self.layout_v.addWidget(self.widget_custom)

changing the generated codeline to the following works, but I would like to avoid this:
self.layout_v.addWidget(self.widget_custom.widget)

my custom Widget (created with Designer) has the following design
Form_custom (QWidget)
^widget (Qwidget)
^^h_layout (QHBoxLayout)
^^^…other components

I tried to remove the (widget)
I tried to use multiple Inheritance for to make the custom Control a plain Widget

class Custom_Widget(Ui_Form_custom, QWidget):

→ both without success

What and how can I do to let the main widget see the custom widget as QWidget and avoid touching the generated code ?
a) generate the custom widget as type QWidget
b) change the design in Designer to generate a QWidget
c) change the placeholder behaviour
d) you ideas

thank you
Michael

Can you share ui file from QtDesigner saved with File / Save menu?

my ui-file is like this:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>Form_custom</class>
 <widget class="QWidget" name="Form_custom">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>368</width>
    <height>344</height>
   </rect>
  </property>
  <property name="sizePolicy">
   <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    <horstretch>1</horstretch>
    <verstretch>1</verstretch>
   </sizepolicy>
  </property>
  <property name="sizeIncrement">
   <size>
    <width>1</width>
    <height>1</height>
   </size>
  </property>
  <property name="baseSize">
   <size>
    <width>1</width>
    <height>1</height>
   </size>
  </property>
  <property name="windowTitle">
   <string>Form</string>
  </property>
  <layout class="QHBoxLayout" name="horizontalLayout">
   <item>
    <widget class="QWidget" name="widget" native="true">
     <property name="sizePolicy">
      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
       <horstretch>1</horstretch>
       <verstretch>1</verstretch>
      </sizepolicy>
     </property>
     <property name="minimumSize">
      <size>
       <width>0</width>
       <height>200</height>
      </size>
     </property>
     <property name="sizeIncrement">
      <size>
       <width>1</width>
       <height>1</height>
      </size>
     </property>
     <property name="baseSize">
      <size>
       <width>1</width>
       <height>1</height>
      </size>
     </property>
     <layout class="QGridLayout" name="gridLayout">
      <item row="0" column="0">
       <widget class="QPushButton" name="pushButton">
        <property name="text">
         <string>PushButton_custom</string>
        </property>
       </widget>
      </item>
     </layout>
    </widget>
   </item>
  </layout>
 </widget>
 <resources/>
 <connections/>
</ui>

perhaps this may be important:
The Class I use inside the designed main is inherited from my designed custom class

class custom2(Ui_Form_custom):
    def __init__(self, parent):
        self.setupUi(parent)    

    def setObjectName(self, a="widget"):
        pass

Did not check yet, but I’m guessing when you create QWidget in QtDesigner you need inherit QWidget in custom2 as well, so:

class custom2(QWidget, Ui_Form_custom):
    def __init__(self, parent):
        self.setupUi(parent)    

    def setObjectName(self, a="widget"):
        pass

Check chapters “Writing Promotable Custom Widgets” (page 444) and “Converting UI files to Python” (page 753).

I will check at my end later today/tomorrow.

EDIT: fix typos…

With your ui run:

pyside6-uic my.ui -o form_custom.py 

got form_custom.py:

# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file 'my.ui'
##
## Created by: Qt User Interface Compiler version 6.7.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
    QMetaObject, QObject, QPoint, QRect,
    QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
    QFont, QFontDatabase, QGradient, QIcon,
    QImage, QKeySequence, QLinearGradient, QPainter,
    QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QGridLayout, QHBoxLayout, QPushButton,
    QSizePolicy, QWidget)

class Ui_Form_custom(object):
    def setupUi(self, Form_custom):
        if not Form_custom.objectName():
            Form_custom.setObjectName(u"Form_custom")
        Form_custom.resize(368, 344)
        sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(Form_custom.sizePolicy().hasHeightForWidth())
        Form_custom.setSizePolicy(sizePolicy)
        Form_custom.setSizeIncrement(QSize(1, 1))
        Form_custom.setBaseSize(QSize(1, 1))
        self.horizontalLayout = QHBoxLayout(Form_custom)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.widget = QWidget(Form_custom)
        self.widget.setObjectName(u"widget")
        sizePolicy.setHeightForWidth(self.widget.sizePolicy().hasHeightForWidth())
        self.widget.setSizePolicy(sizePolicy)
        self.widget.setMinimumSize(QSize(0, 200))
        self.widget.setSizeIncrement(QSize(1, 1))
        self.widget.setBaseSize(QSize(1, 1))
        self.gridLayout = QGridLayout(self.widget)
        self.gridLayout.setObjectName(u"gridLayout")
        self.pushButton = QPushButton(self.widget)
        self.pushButton.setObjectName(u"pushButton")

        self.gridLayout.addWidget(self.pushButton, 0, 0, 1, 1)


        self.horizontalLayout.addWidget(self.widget)


        self.retranslateUi(Form_custom)

        QMetaObject.connectSlotsByName(Form_custom)
    # setupUi

    def retranslateUi(self, Form_custom):
        Form_custom.setWindowTitle(QCoreApplication.translate("Form_custom", u"Form", None))
        self.pushButton.setText(QCoreApplication.translate("Form_custom", u"PushButton_custom", None))
    # retranslateUi

than I make my.py:

import sys
from PySide6.QtWidgets import QApplication, QWidget
from form_custom import Ui_Form_custom


class MainWindow(QWidget, Ui_Form_custom):
    def __init__(self):
        super().__init__()
        self.setupUi(self)


app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()

when I run it:

So, what you try to do?