Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Text across multiple columns in one row like colspan in HTML
Forum Updated to NodeBB v4.3 + New Features

Text across multiple columns in one row like colspan in HTML

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • WolleKetteW Offline
    WolleKetteW Offline
    WolleKette
    wrote on last edited by
    #1

    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.

    JonBJ 1 Reply Last reply
    0
    • WolleKetteW WolleKette

      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.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @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.

      WolleKetteW 1 Reply Last reply
      0
      • JonBJ JonB

        @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.

        WolleKetteW Offline
        WolleKetteW Offline
        WolleKette
        wrote on last edited by
        #3

        @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()
        
        1 Reply Last reply
        0
        • WolleKetteW Offline
          WolleKetteW Offline
          WolleKette
          wrote on last edited by
          #4

          @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 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved