Results 1 to 7 of 7

Thread: QTableWidget (resizing rows, turning off selection, etc.)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Oct 2006
    Posts
    279
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 40 Times in 39 Posts

    Default Re: QTableWidget (resizing rows, turning off selection, etc.)

    As to your first question, add the line:
    Qt Code:
    1. tbl->setEditTriggers(QAbstractItemView::NoEditTriggers);
    To copy to clipboard, switch view to plain text mode 

    And if you want all rows to have equal size you should probably implement a delegate. ie.:
    Qt Code:
    1. class ItemDelegate : public QItemDelegate
    2. {
    3. virtual QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
    4. {
    5. return QItemDelegate::sizeHint(option, index).expandedTo(QSize(0,20));
    6. }
    7. };
    8.  
    9. ...
    10. tbl->setItemDelegate(new ItemDelegate);
    11. ...
    12. tbl->resizeRowsToContents();
    13. ...
    To copy to clipboard, switch view to plain text mode 

    or reimplement QTableView::sizeHintForRow(int row) to always return the desired height.
    Last edited by spud; 8th January 2007 at 10:14.

Similar Threads

  1. QTableWidget Sorting Multiple Selection
    By rhiacasta in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2006, 21:05
  2. Replies: 6
    Last Post: 5th March 2006, 21:05

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.