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. Minimum width for a QTreeWidget in order not to display horizontal scrollbar
Forum Updated to NodeBB v4.3 + New Features

Minimum width for a QTreeWidget in order not to display horizontal scrollbar

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.9k 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.
  • Z Offline
    Z Offline
    zapprox
    wrote on 3 Feb 2017, 07:25 last edited by
    #1

    Hi,
    I use a QTreeWidget, a QMdiArea and a QSplitter between them. QTreeWidget has multiple columns and all set to resizeColumnToContents. So after adding some data header width can be updated according to the data. What I want to achieve is to get the minimum width in order not to display horizontal scrollbar so I can resize QSplitter and whole data can be displayed without need a scrollbar.
    Regards.

    V 1 Reply Last reply 3 Feb 2017, 08:54
    0
    • Z zapprox
      3 Feb 2017, 07:25

      Hi,
      I use a QTreeWidget, a QMdiArea and a QSplitter between them. QTreeWidget has multiple columns and all set to resizeColumnToContents. So after adding some data header width can be updated according to the data. What I want to achieve is to get the minimum width in order not to display horizontal scrollbar so I can resize QSplitter and whole data can be displayed without need a scrollbar.
      Regards.

      V Offline
      V Offline
      Venkatesh V
      wrote on 3 Feb 2017, 08:54 last edited by
      #2

      Hi @zapprox

      Instead of using resizeColumnToContents, use setColumnWidth(int,int) to every columns.

      Z 1 Reply Last reply 3 Feb 2017, 11:16
      1
      • V Venkatesh V
        3 Feb 2017, 08:54

        Hi @zapprox

        Instead of using resizeColumnToContents, use setColumnWidth(int,int) to every columns.

        Z Offline
        Z Offline
        zapprox
        wrote on 3 Feb 2017, 11:16 last edited by
        #3

        @Venkatesh-V In this option I think I have to calculate the width of the text using QFontMetrics beacause the header text is not static. However resizeColumnToContents already calculates. So I think I'll go on with resizeColumnToContents . Thank you for your response.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zapprox
          wrote on 6 Feb 2017, 16:28 last edited by
          #4

          I was able to get the width of the columns with calling QTreeWidget's header method and then get the section size for each columns. My calls were like; "m_treeWidget->header()->sectionSize(0);" .Besides there were 2 pixels gap for each column that sholud be considered.

          1 Reply Last reply
          1

          1/4

          3 Feb 2017, 07:25

          • Login

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