Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QTreeView - Horizontal scroll bar is not working properly

    General and Desktop
    2
    9
    4225
    Loading More Posts
    • 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
      kumararajas last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • K
          kumararajas @SGaist last edited by

          @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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • K
              kumararajas @SGaist last edited by

              @SGaist Am using QStandardItemModel..

              --Kumar

              K 1 Reply Last reply Reply Quote 0
              • K
                kumararajas @kumararajas last edited by

                @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 Reply Quote 0
                • K
                  kumararajas last edited by

                  This is still open.

                  Any thoughts on this problem?

                  --Kumar

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    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 Reply Quote 0
                    • K
                      kumararajas @SGaist last edited by

                      @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 Reply Quote 0
                      • First post
                        Last post