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. Qt::SizeHintRole isn't adjusting the height of a QTableView Row?
Qt 6.11 is out! See what's new in the release blog

Qt::SizeHintRole isn't adjusting the height of a QTableView Row?

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

    I have a QTableView where one column needs to contain both the image and text. What I have is a model that returns the QPixmap on the Qt::DecorationRole and the text on Qt::DisplayRole. The problem is the height of each row cuts off the image. How exactly do I get the height to adjust to that of the image?

    I tried returning the QSize of the QPixmap on the Qt::SizeHintRole, but then there is no image at all.

    What am I missing?

    SAm

    1 Reply Last reply
    0
    • S Offline
      S Offline
      scarleton
      wrote on last edited by
      #2

      There where a number of steps, most of them I got from here:

      http://developer.qt.nokia.com/faq/answer/how_can_i_change_the_row_height_of_a_qtreeview

      I had to set QTableView::resizeRowsToContents to true and implement the QItemDelegate::sizeHint. In implementing the sizeHint, I had to get into the model, get the image, and return the size of the image. Once I did that, it sized correctly for me.

      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