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. How to enable RootIsDecorated in QTreeView if the first column is hidden
Forum Updated to NodeBB v4.3 + New Features

How to enable RootIsDecorated in QTreeView if the first column is hidden

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 1.1k Views 2 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.
  • I Offline
    I Offline
    Infinity
    wrote on last edited by
    #1

    If I hide the first column in a QTreeView the root decorate disappears even if setRootIsDecorated is set to true.

    m_ui->treeView->setModel(m_sqlTreeModel);
    m_ui->treeView->hideColumn(0);
    m_ui->treeView->setRootIsDecorated(true);
    

    How can I enable the root decorate, when I hide the first column?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Well, technically you are hiding the root index so it's not going to be painted.

      What exactly are you after ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      I 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Well, technically you are hiding the root index so it's not going to be painted.

        What exactly are you after ?

        I Offline
        I Offline
        Infinity
        wrote on last edited by
        #3

        @SGaist I would like have just one column in the tree view and would like to hide the first and the second column of the model and have the root decoration in front of the third column.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AndreasF
          wrote on last edited by
          #4

          Hallo,
          I have the same question and have not come across an answer yet. How do I get the branch drawn when the first column is hidden.

          Christian EhrlicherC 1 Reply Last reply
          0
          • A AndreasF

            Hallo,
            I have the same question and have not come across an answer yet. How do I get the branch drawn when the first column is hidden.

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @AndreasF said in How to enable RootIsDecorated in QTreeView if the first column is hidden:

            How do I get the branch drawn when the first column is hidden.

            Don't hide the first column - the decoration belongs to the first column. Since you're creating the model I don't see why the first column must be hidden - simply move that data to another column in your model.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            A 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              @AndreasF said in How to enable RootIsDecorated in QTreeView if the first column is hidden:

              How do I get the branch drawn when the first column is hidden.

              Don't hide the first column - the decoration belongs to the first column. Since you're creating the model I don't see why the first column must be hidden - simply move that data to another column in your model.

              A Offline
              A Offline
              AndreasF
              wrote on last edited by
              #6

              @Christian-Ehrlicher
              Hello Christian,

              of course you are right that I am in control of the displayed data and sequence on my own model. However, there are circumstances that would suggest that I have a present structure and for whatever reason I want to hide columns. Therefore I hoped that the QTreeView for the display of the branches can be configured to always display the node (expand/collapse) in the first visible column.

              JonBJ 1 Reply Last reply
              0
              • A AndreasF

                @Christian-Ehrlicher
                Hello Christian,

                of course you are right that I am in control of the displayed data and sequence on my own model. However, there are circumstances that would suggest that I have a present structure and for whatever reason I want to hide columns. Therefore I hoped that the QTreeView for the display of the branches can be configured to always display the node (expand/collapse) in the first visible column.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @AndreasF
                Given the behaviour it apparently has, maybe you could insert a QIdentityProxyModel-derived class between the view and your model to "map" the first visible column to be the first one if that is required?

                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