QTextEdit as a child node for QTreeWidgetItem?
<p>Is it possible to add a QTextEdit as a child in QTreeWidget?</p>

<p>Here is my code we can create a QTreeWidget and add the columns:</p>

<pre><code>self.treetext = QtGui.QTreeWidget(self.dockWidgetContents_2)
        self.treetext.setObjectName(_fromUtf8("treetext"))
        self.verticalLayout_2.addWidget(self.treetext)
        self.treetext.setGeometry(QtCore.QRect(20, 10, 261, 241))
        item_0 = QtGui.QTreeWidgetItem(self.treetext)
        item_1 = QtGui.QTreeWidgetItem(item_0)
        item_1 = QtGui.QTreeWidgetItem(item_0)
        item_1 = QtGui.QTreeWidgetItem(item_0)
        item_1 = QtGui.QTreeWidgetItem(item_0)
        item_0 = QtGui.QTreeWidgetItem(self.treetext)
        item_1 = QtGui.QTreeWidgetItem(item_0)
        item_1 = QtGui.QTreeWidgetItem(item_0)
        item_1 = QtGui.QTreeWidgetItem(item_0)
        item_1 = QtGui.QTreeWidgetItem(item_0)
</code></pre>

<p>and add new items as child:</p>

<pre><code>self.treetext.headerItem().setText(0, _translate("Form", "Model List", None))
        __sortingEnabled = self.treetext.isSortingEnabled()
        self.treetext.setSortingEnabled(False)
        self.treetext.topLevelItem(0).setText(0, _translate("Form", "Model 1", None))
        self.treetext.topLevelItem(0).child(0).setText(0, _translate("Form", "New Subitem", None))
        self.treetext.topLevelItem(0).child(1).setText(0, _translate("Form", "New Item", None))
        self.treetext.topLevelItem(0).child(2).setText(0, _translate("Form", "New Item", None))
        self.treetext.topLevelItem(0).child(3).setText(0, _translate("Form", "New Item", None))
        self.treetext.topLevelItem(1).setText(0, _translate("Form", "Model 2", None))
        self.treetext.topLevelItem(1).child(0).setText(0, _translate("Form", "New Subitem", None))
        self.treetext.topLevelItem(1).child(1).setText(0, _translate("Form", "New Item", None))
        self.treetext.topLevelItem(1).child(2).setText(0, _translate("Form", "New Item", None))
        self.treetext.topLevelItem(1).child(3).setText(0, _translate("Form", "New Item", None))
        self.treetext.setSortingEnabled(__sortingEnabled)
</code></pre>

<p>Can Create a new QTextEdit with other example:</p>

<pre><code>self.groupBox = QtGui.QTextEdit(self.dockWidgetContents_2)
self.groupBox.setObjectName(_fromUtf8("groupBox"))
self.verticalLayout_2.addWidget(self.groupBox)
</code></pre>

<p>But can we put QTextEdit as a new child for QTreeWidgetItem?</p>

<p>You can set a widget on any item in the tree using <a href="http://pyqt.sourceforge.net/Docs/PyQt4/qtreewidget.html#setItemWidget" rel="nofollow"><code>setItemWidget</code></a></p>

<pre><code>self.treetext.setItemWidget(item_1, 0, QTextEdit(self))
</code></pre>

<p>If your tree widget items are editable, you can also just tell Qt to open a persistent editor (by default, <code>QTreeWidgetItems</code> use a <code>QLineEdit</code> for editing, but you can override that behavior with a <code>QItemDelegate</code> if you want) using <a href="http://pyqt.sourceforge.net/Docs/PyQt4/qtreewidget.html#openPersistentEditor" rel="nofollow"><code>openPersistentEditor()</code></a></p>

<pre><code>self.treetext.openPersistentEditor(item_1, 0)
</code></pre>

python pyqt pyqt4 qtextedit qtreewidget