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: Extra Column Space [Solved]
Forum Updated to NodeBB v4.3 + New Features

QTableview: Extra Column Space [Solved]

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 7.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.
  • M Offline
    M Offline
    mr_gui
    wrote on last edited by
    #1

    Hi,
    I'm starting with QTableView and haven't much experience with it. So maybe I have overseen sth. obvious.

    I try to display an image in every cell. Some images are doublesized so I try to display them in two columns or to rows. But when I set the column.width() = image.width() there is still a small margin (maybe 2 pixels) at the left side of the cell (and therefore between the imageparts). I tried to set every margin and so on to 0 but nothing changes.

    Can anyone help?

    Edit: removed [Closed] tag, and replaced it by [Solved]; Andre

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vinb
      wrote on last edited by
      #2

      Does this work for you?
      void QTableView::resizeRowToContents ( int row ) [slot]

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mr_gui
        wrote on last edited by
        #3

        thank you for your reply, but no it doesn't work. i do this to resize the cells to the optimal size but the empty space still stays the same.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vinb
          wrote on last edited by
          #4

          Mayby you find a solution in:
          @
          void QTableView::setSpan ( int row, int column, int rowSpanCount, int columnSpanCount )@

          Dont know exactly what it does (never worked with tableview), but you can try

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mr_gui
            wrote on last edited by
            #5

            thank you, but i tried this befor and it doesnt seem to work. it is noct, that the cell has not the correct size, it is that left oft the pixmap there is some extra space where no space is wanted. when i resize the cell to a smaller size, the extra space still appears.

            maybe it has sth. to do with the headers or the item delgate? any ideas?

            here a list of what i have tried so far:

            @void setColumnWidth ( int column, 0 )
            void setSpan ( int row, int column, 0, 0 )
            setAutoScrollMargin (0 )
            resizeColumnToContents ( int column )
            resizeRowsToContents ()@

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vinb
              wrote on last edited by
              #6

              sorry, i cant be of any help now.
              I hope for you that one of the guru's know how to solve your problem.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sigrid
                wrote on last edited by
                #7

                In order to specify the margins internally in a cell, you can subclass the style and reimplement pixelMetric() to return the value you want from PM_FocusFrameHMargin. See the documentation:

                http://doc.qt.nokia.com/qstyle.html#pixelMetric

                Alternatively, you can reimplement paint() for the item delegate to draw the margins as you want.

                http://doc.qt.nokia.com/qstyleditemdelegate.html#paint

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mr_gui
                  wrote on last edited by
                  #8

                  I use delegates now, thank you.

                  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