Text across multiple columns in one row like colspan in HTML
-
wrote on 5 Aug 2022, 08:46 last edited by
Hello at all,
I use Python and pyside6 and I have a QTreeWidget with some rows (QTreeWidgetItem) and multiple columns. The rows are organized hierarchically by which I mean that there are parent and child nodes.Now I want to place a text in the parent nodes which go over several columns. Like colspan in html for example.
I've been looking around for ages, but haven't found anything. That can not be. Somehow I'm looking in the wrong place. Please give me a tip.
-
Hello at all,
I use Python and pyside6 and I have a QTreeWidget with some rows (QTreeWidgetItem) and multiple columns. The rows are organized hierarchically by which I mean that there are parent and child nodes.Now I want to place a text in the parent nodes which go over several columns. Like colspan in html for example.
I've been looking around for ages, but haven't found anything. That can not be. Somehow I'm looking in the wrong place. Please give me a tip.
wrote on 5 Aug 2022, 09:47 last edited by@WolleKette said in Text across multiple columns in one row like colspan in HTML:
Now I want to place a text in the parent nodes which go over several columns
There is QTreeView::setFirstColumnSpanned(). I think that's all for a
QTreeView
/QTreeWidget
. Otherwise have a look at https://stackoverflow.com/questions/27149733/qtreeview-merge-some-cells. -
@WolleKette said in Text across multiple columns in one row like colspan in HTML:
Now I want to place a text in the parent nodes which go over several columns
There is QTreeView::setFirstColumnSpanned(). I think that's all for a
QTreeView
/QTreeWidget
. Otherwise have a look at https://stackoverflow.com/questions/27149733/qtreeview-merge-some-cells.wrote on 5 Aug 2022, 16:15 last edited by@JonB said in Text across multiple columns in one row like colspan in HTML:
There is QTreeView::setFirstColumnSpanned(). I think that's all for a QTreeView/QTreeWidget.
I saw the setFirstColumnSpanned Method in the documentation but I have no idea how it should work and I didn’t found examples.
When I create a new node as follows and insert it in the tree, the text is still limited to the column width.
... node = QTreeWidgetItem(['Some very long text']) node.setFirstColumnSpanned(True) tree.addTopLevelItem(node) ... insert some child nodes ... tree.expandAll()
-
wrote on 5 Aug 2022, 16:23 last edited by
@WolleKette said in Text across multiple columns in one row like colspan in HTML:
Oh, just now I had an idea. The trick is to call setFirstColumnSpanned after adding the node to the tree.
Then it works.
1/4