Results 1 to 9 of 9

Thread: QTableView appropriate size

  1. #1
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QTableView appropriate size

    Hello !

    I have form with tableView. Code is

    class Form : public QDialog
    {
    ...
    QTableView *tableView;
    ...
    };

    class SearchTableModel : public QAbstractTableModel
    {
    ...
    };

    class SearchTableDelegate : public QAbstractDelegate
    {
    ...
    };

    Can I programmatically resize tableView and its parent form to appropriate size or fill all available space of tableView ?

    --
    Best regards,
    Sincerely yours,
    Yuriy Rusinov

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView appropriate size

    Quote Originally Posted by YuriyRusinov
    or fill all available space of tableView ?
    You can achieve this by setting resizeMode to QHeaderView::Stretch.

    See QHeaderView::setResizeMode().

  3. #3
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QTableView appropriate size

    OK, I did it, but form width is less than output text, which way I have to resize form in order to reduce horizontal scrollbar on tableView ?

  4. #4
    Join Date
    May 2006
    Posts
    28
    Thanks
    8
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableView appropriate size

    hello,

    I think I have the same problem. The last header in the QTreeView gets shrunk by the horizontal scroll bar.

    The function:
    void setStretchLastSection ( bool stretch )

    does'nt work for me, although It seems it should.
    I allow the user to resize header sections and save the size using QSettings.
    After I resize them, the last header doesnt display its full size because of the horizontal scroll bar resizes it.

    Let me know if you find a solution.
    Many thanks,
    Neil

  5. #5
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QTableView appropriate size

    Of course, I post solution on this forum.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView appropriate size

    Quote Originally Posted by YuriyRusinov
    OK, I did it, but form width is less than output text, which way I have to resize form in order to reduce horizontal scrollbar on tableView ?
    You could try QWidget::resize(), but I'm not sure how to get the exact size. Maybe QTreeView::columnWidth() will help.

  7. #7
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QTableView appropriate size

    OK, I'll try.

  8. #8
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QTableView appropriate size

    OK, I solved this problem using QTreeView and treemodel. Thanks.

  9. #9
    Join Date
    May 2006
    Posts
    28
    Thanks
    8
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableView appropriate size

    Quote Originally Posted by Big Duck

    The function:
    void setStretchLastSection ( bool stretch )

    does'nt work for me, although It seems it should.

    well it does work for me after all, tried false instead of true

Similar Threads

  1. QTableView sorting
    By gabriels in forum Qt Programming
    Replies: 11
    Last Post: 6th October 2010, 17:13
  2. QTableView currentChanged <> selecting header
    By Everall in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2009, 08:24
  3. QDockWidget Size
    By kiker99 in forum Qt Programming
    Replies: 9
    Last Post: 31st March 2007, 16:15
  4. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.