Results 1 to 9 of 9

Thread: QTableView +rowHeight

  1. #1
    freeskydiver Guest

    Default QTableView +rowHeight

    I have a QTableView and all is ready, but I can't setup the rowHeight property. Who can help me? thanks in advance...

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView +rowHeight

    How exactly do you use setRowHeight?

  3. #3
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: QTableView +rowHeight

    this should do what you want:

    Qt Code:
    1. QTableView m_tableView = new QTableView(this);
    2. m_tableView->verticalHeader()->setDefaultSectionSize(20); //setHeight
    3. m_tableView->setModel(myModel);
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to darksaga for this useful post:


  5. #4
    freeskydiver Guest

    Default Re: QTableView +rowHeight

    Quote Originally Posted by marcel View Post
    How exactly do you use setRowHeight?
    Yes, but this property want setup for each row.
    I look for a thing like
    setDefaultRowHeight(20);

  6. #5
    freeskydiver Guest

    Default Re: QTableView +rowHeight

    Quote Originally Posted by darksaga View Post
    this should do what you want:

    Qt Code:
    1. m_tableView->verticalHeader()->setDefaultSectionSize(20); //setHeight
    To copy to clipboard, switch view to plain text mode 
    Well, nice name for this function But this work not, too. ;( I got no changing.
    Sorry, I test now with this function setResizeMode() function inherent.

  7. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableView +rowHeight

    As a side note (and like darksaga's example shows), QHeaderView::setDefaultSectionSize() must be called before attaching a model to the table view.
    J-P Nurmi

  8. #7
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: QTableView +rowHeight

    Quote Originally Posted by freeskydiver View Post
    Well, nice name for this function But this work not, too. ;( I got no changing.
    Sorry, I test now with this function setResizeMode() function inherent.
    Had also probs with the rowheight when i used QTableView first.

    My experience is that it depends on the order how you setup your model & tabel and where you call
    Qt Code:
    1. m_tableView->verticalHeader()->setDefaultSectionSize(20);
    To copy to clipboard, switch view to plain text mode 

    Try to call setDefaultSectionSize @ a different place.

    afaik, it will always work with the order I posted above.

  9. #8
    freeskydiver Guest

    Default Re: QTableView +rowHeight

    Quote Originally Posted by freeskydiver View Post
    Well, nice name for this function But this work not, too. ;( I got no changing.
    Sorry, I test now with this function setResizeMode() function inherent.
    How anytime, the error to sit in the front of the monitor
    I have later used resizeRowsToContents();

  10. #9
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Exclamation Re: QTableView +rowHeight

    Be careful:

    If you have a table with many rows & columns resizeRowsToContents && resizeColumnsToContents could slow down your app drastically.

    in the project I'm currently developing I had to ban these due to servere slowdowns...

Similar Threads

  1. Set height of QTableView to fit exact number of rows.
    By Ben.Hines in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2019, 01:49
  2. QTableView sorting
    By gabriels in forum Qt Programming
    Replies: 11
    Last Post: 6th October 2010, 17:13
  3. QTableView currentChanged <> selecting header
    By Everall in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2009, 08:24
  4. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  5. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49

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.