Results 1 to 2 of 2

Thread: How can I set the row height and column width of a QTableView?

  1. #1
    Join Date
    Mar 2013
    Posts
    43
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How can I set the row height and column width of a QTableView?

    I am having text and Image in one row and other rows are having only text. I want to set the height of row to the content of the row. So I am using ui->tableView->resizeColumnsToContents();
    ui->tableView->resizeRowsToContents();

    1)All other rows are resizing except the row which containing the image and test.
    2) How to break the text in the row if its long and then set the width of column.

    Please hrlp me in setting the height of rows and width of column in TableView.

  2. #2
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I set the row height and column width of a QTableView?

    Qt Code:
    1. QVariant YourTableViewModel::data( const QModelIndex &index, int role ) const
    2. {
    3. ...
    4.  
    5. if (role == Qt::SizeHintRole)
    6. {
    7. ...
    8. }
    9.  
    10. ...
    11. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Widget Height and Width
    By in_dbasu in forum Qt Programming
    Replies: 3
    Last Post: 11th August 2011, 08:44
  2. Replies: 1
    Last Post: 25th February 2011, 11:46
  3. Column width sensitive kerning in QTableView
    By Debilski in forum Qt Programming
    Replies: 2
    Last Post: 22nd October 2009, 19:11
  4. How to set QTableView width to width of horizontal header?
    By martinb0820 in forum Qt Programming
    Replies: 0
    Last Post: 2nd December 2008, 20:51
  5. width and height of QTabWidget
    By chikkireddi in forum Qt Programming
    Replies: 6
    Last Post: 29th October 2007, 13: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.