Results 1 to 2 of 2

Thread: QTableWidget - how to place specific cell in top-left corner of viewport?

  1. #1
    Join Date
    Dec 2011
    Posts
    60
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTableWidget - how to place specific cell in top-left corner of viewport?

    I'm using a QTableWidget and want to provide the ability to "zoom to the selected cells". This necessitates that, post-zoom, I put a specific cell in the top-left corner of the viewport.

    The steps for this would be:


    1. Allow the user to make a free selection of a range of cells
    2. Resize all the cells, so that the selected geometry will exactly fill the available viewport size
    3. Scroll the table so the top-left corner of the selection appears in the top-left corner of the viewport


    The problem lies in step #3.

    I'm using scrollToItem(), but this does not provide enough options to guarantee that the item will be scrolled to the top-left corner of the viewport. The only options available are PositionAtCenter, PositionAtBottom, PositionAtTop, EnsureVisible.

    What is really needed is a PositionAtTopLeft.

    The problem can be seen in the attached screenshots. I need cell #404 to be in the top-left corner.

    Is there a way to place a specific cell in the top-left corner with QTableWidget?

    Table_zoom1.jpg
    Table_zoom2.jpg
    Table_zoom3.jpg

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTableWidget - how to place specific cell in top-left corner of viewport?

    Seems like you should be able to combine QTableView::columnViewportPosition() and rowViewportPortPosition() with scroll() to position the cell.

  3. The following user says thank you to ChrisW67 for this useful post:

    alketi (13th May 2013)

Similar Threads

  1. Replies: 4
    Last Post: 13th February 2011, 20:24
  2. Replies: 4
    Last Post: 30th May 2010, 12:55
  3. Replies: 10
    Last Post: 29th May 2010, 18:42
  4. Replies: 1
    Last Post: 25th May 2010, 14:44
  5. QTableWidget - Using top left corner cell
    By SteveH in forum Newbie
    Replies: 6
    Last Post: 12th March 2010, 19:33

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.