Results 1 to 3 of 3

Thread: Layout manager for TableView

  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Layout manager for TableView

    I have a tableview with several columns. I would like the size of the columns in the table to adjust depending on the window size, but I would also like to apply sizing hints to the layout manager so the columns get resized appropriately. For example, apply 1/8th of the space to column 2, 3/8th's of the space to column 1, and the rest to column 3.

    Is this possible? I've seen the "resize based on contents" but this isn't what I'm after, and seem to disable user control of the column sizes.

  2. #2
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2
    Thanked 29 Times in 28 Posts

    Default Re: Layout manager for TableView

    I think you should subclass from QTableView an reimplement the resizeEvent (http://doc.trolltech.com/4.5/qabstra...ml#resizeEvent).

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: Layout manager for TableView

    You don't think reimplementing sizeHintForColumn is enough? (Not sure exactly what it does, hence the question, I'm just guessing here from information in QtAssistant)

    EDIT: resizeEvent seems to work fine, and the values it gives are perfect. I usually end up calling all kinds of strange functions to work out invisible borders, whether or not the scroll bar needs to be there and if so work out the size of that, etc, but not in Qt. I like it :-) The fact that you can subclass a component in the designer is a real plus too, I've not seen that in any other environment.
    Last edited by squidge; 20th October 2009 at 20:56.

Similar Threads

  1. Custon Layout Manager
    By kb1lqc in forum Qt Programming
    Replies: 2
    Last Post: 2nd September 2009, 16:05
  2. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 20:21
  3. Qt like Layout Manager available for .NET platform
    By vkhaitan in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2008, 13:36
  4. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 17:11
  5. writing a layout manager
    By jayw710 in forum Qt Programming
    Replies: 2
    Last Post: 15th February 2006, 23:53

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
  •  
Qt is a trademark of The Qt Company.