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. Dynamically resize rows in QTableView based on the delegate's editor size
Forum Updated to NodeBB v4.3 + New Features

Dynamically resize rows in QTableView based on the delegate's editor size

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.7k 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.
  • P Offline
    P Offline
    panosk
    wrote on last edited by
    #1

    Hi,

    I'm using a QTableView with a custom QStyledItemDelegate that uses QTextEdits for display and editing. I have reimplemented all the necessary functions for the delegate and I have setup the resizeModes in the view so when I insert or remove text in the editors (cells) the view updates itself and resizes the rows based on their contents. But this happens after I leave the edited cell.

    I would like to have the row resize dynamically while adding or removing text. Any hints how I should approach this will be appreciated.

    Thanks in advance.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      panosk
      wrote on last edited by
      #2

      Allow me a gentle bump with a little more info.

      I realize that I have to use signals and slots to achieve this. My confusion is what signals and slots I should use in all three classes (QTextEdit, QStyledItemDelegate, and QTableView) to do the work. Currently, in the custom QTextEdit class I have connected the textChanged() signal to a custom slot that resizes the QTextEdit as text is added or removed. This indeed works in the table view but the row doesn't resize automatically too so, while editing a cell, the QTextEdit overlaps to the next row. After I leave the edited cell, the row resizes properly.

      I suppose I will have to connect a signal from the delegate to the resizeRowToContents(int) slot in the QTableView and that's where I could use some help.

      TIA

      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