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. QTableView::resizeRowsToContents() problem
Forum Updated to NodeBB v4.3 + New Features

QTableView::resizeRowsToContents() problem

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 582 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.
  • ivanicyI Offline
    ivanicyI Offline
    ivanicy
    wrote on last edited by
    #1

    Hello!

    I have a function that loads data in a QTableView. I call this function from the constructor and after that, I call to "resizeRowsToContents()" but it doesn't work and shows the rows very wide. When I call resizeRowsToContents() function with a QPushButton event, for example, it works fine.

    I think it is because of I am calling it in the constructor. I tried using QTableView::repaint() and QTableView::update() without success.

    What can I do to fix it?

    Thank you very much!

    JonBJ 1 Reply Last reply
    0
    • ivanicyI ivanicy

      Hello!

      I have a function that loads data in a QTableView. I call this function from the constructor and after that, I call to "resizeRowsToContents()" but it doesn't work and shows the rows very wide. When I call resizeRowsToContents() function with a QPushButton event, for example, it works fine.

      I think it is because of I am calling it in the constructor. I tried using QTableView::repaint() and QTableView::update() without success.

      What can I do to fix it?

      Thank you very much!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @ivanicy
      It needs to be called from https://doc.qt.io/qt-5/qwidget.html#showEvent rather than constructor.

      ivanicyI 1 Reply Last reply
      3
      • JonBJ JonB

        @ivanicy
        It needs to be called from https://doc.qt.io/qt-5/qwidget.html#showEvent rather than constructor.

        ivanicyI Offline
        ivanicyI Offline
        ivanicy
        wrote on last edited by
        #3

        @JonB Thank you very much!! It works perfectly!

        JonBJ 1 Reply Last reply
        0
        • ivanicyI ivanicy

          @JonB Thank you very much!! It works perfectly!

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @ivanicy
          Up to you, but if you allow the containing window to be resized such that the QTableView changes size, you might want to call it from a resize event too.

          1 Reply Last reply
          1

          • Login

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