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 29 Mar 2016, 13:59 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 29 Mar 2016, 14:30 last edited by
      #2

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

      T 1 Reply Last reply 29 Mar 2016, 14:58
      0
      • M mrjj
        29 Mar 2016, 14:30

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

        T Offline
        T Offline
        tokafr
        wrote on 29 Mar 2016, 14:58 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.

        M 1 Reply Last reply 29 Mar 2016, 15:15
        0
        • T tokafr
          29 Mar 2016, 14:58

          @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.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 29 Mar 2016, 15:15 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 29 Mar 2016, 18:08 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

            1/5

            29 Mar 2016, 13:59

            • Login

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