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. Set minimum column width to QTableView.

Set minimum column width to QTableView.

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtableviewqheaderviewmvcmodel-view
5 Posts 3 Posters 24.3k 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.
  • T Offline
    T Offline
    tokafr
    wrote on last edited by
    #1

    Hello
    I have QTableView with model and delegate. I have several columns. So I can resize them by mouse, But now I need to set a minimum width for the first column. So this column's width shouldn't be less then some number(100) for example. How is this possible?
    thanks.

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

      hi
      like
      http://doc.qt.io/qt-5/qtableview.html#setColumnWidth
      ?

      T 1 Reply Last reply
      0
      • mrjjM mrjj

        hi
        like
        http://doc.qt.io/qt-5/qtableview.html#setColumnWidth
        ?

        T Offline
        T Offline
        tokafr
        wrote on last edited by
        #3

        @mrjj
        thanks for answer, but it's not what I want, As I guess it sets default width to the column, which can be resized but I need the minimum width So that column couldn't be resized to be smaller than this value. I need something like setMinimumColumnWidth(int column, int value) or something like that.

        mrjjM 1 Reply Last reply
        0
        • T tokafr

          @mrjj
          thanks for answer, but it's not what I want, As I guess it sets default width to the column, which can be resized but I need the minimum width So that column couldn't be resized to be smaller than this value. I need something like setMinimumColumnWidth(int column, int value) or something like that.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @tokafr said:

          hmm i know no such method. sorry.
          and
          resizeColumnsToContents()
          is still not good enough as you want to limit resize.

          Give it some time, good change some of the others will know a way.

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

            Hi,

            You can try with the QHeaderView::minimumSectionSize property

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

            1 Reply Last reply
            2

            • Login

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