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. QTreeView - Horizontal scroll bar is not working properly

QTreeView - Horizontal scroll bar is not working properly

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 4.9k Views
  • 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.
  • K Offline
    K Offline
    kumararajas
    wrote on last edited by
    #1

    Hi,

    I am facing difficulties with the horizontal scroll bar in Qtreeview.

    When I expand and the content exceeds the widget, I expect that scroll bar should appear.

        projectTreeView->header()->setMinimumWidth(1000);
    
        projectTreeView->header()->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    
        projectTreeView->setTextElideMode(Qt::ElideNone);
        projectTreeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
        projectTreeView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
        projectTreeView->setSelectionBehavior(QAbstractItemView::SelectRows);
        projectTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
        projectTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    

    These are the properties I have set.

    What happens is that,
    After crossing 1000, I do get a scroll bar, but, it doesn't grow as when I keep expanding the tree.

    How do I get the better control?

    Thanks,
    Kumara

    --Kumar

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

      Hi,

      Out of curiosity, why do you need to modify your header ?

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

      K 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Out of curiosity, why do you need to modify your header ?

        K Offline
        K Offline
        kumararajas
        wrote on last edited by
        #3

        @SGaist I thought that's the way to get the control on sizing.

        If that is not correct, can you please recommend me the right way?

        Thanks,
        Kumara

        --Kumar

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

          AFAIK, by default the QTreeView will do what you want without any special handling. What model are you using ?

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

          K 1 Reply Last reply
          0
          • SGaistS SGaist

            AFAIK, by default the QTreeView will do what you want without any special handling. What model are you using ?

            K Offline
            K Offline
            kumararajas
            wrote on last edited by
            #5

            @SGaist Am using QStandardItemModel..

            --Kumar

            K 1 Reply Last reply
            0
            • K kumararajas

              @SGaist Am using QStandardItemModel..

              K Offline
              K Offline
              kumararajas
              wrote on last edited by
              #6

              @kumararajas When I did a quick test, QTableView and QListView works good with respect to horizontal scroll bar.

              But, QTreeView is having some problems around. Not sure why.

              Can you please share any example or sample code where Horizontal scroll bar works good in QTreeView? I can use that as my reference and check what am I doing wrong.

              Thanks,
              Kumara

              --Kumar

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kumararajas
                wrote on last edited by
                #7

                This is still open.

                Any thoughts on this problem?

                --Kumar

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

                  Can you provide a minimal compilable sample application that triggers that ?

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

                  K 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Can you provide a minimal compilable sample application that triggers that ?

                    K Offline
                    K Offline
                    kumararajas
                    wrote on last edited by
                    #9

                    @SGaist Good question :)

                    I have the implementation as part of my project. Let me see if I have strip of my code from the same and share it here. Else, I can also try a sample application which can reproduce this problem and share it here.

                    --Kumar

                    1 Reply Last reply
                    0

                    • Login

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