Results 1 to 3 of 3

Thread: qtableview QStandardItemModel read only

Threaded View

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

    Default Re: qtableview QStandardItemModel read only

    Set QAbstractItemView::NoEditTriggers with QTableView::setEditTriggers.

    For the second problem, you either make the selection model available in the delegate(an easy solution), or for every item you add some custom boolean data(for a user role) which tells you if the item is selected or not.


    For the first solution, you can pass the view as the delegate's parent when you construct it. You can cast parent() inside the delegate back to the view and access its selection model.
    For the second solution, you can get the data for your role in the delegate's paint and see if it is selected.

    EDIT: I think you can use QStyleOptionViewItem::state variable. If it QStyle::State_selected, then the item is selected. I am not sure if it contains valid values when it is passed to you.

    EDIT2: I just had a look at the QItemDelegate::paint implementation. It seems that QStyleOptionView::state is valid, so you can just test for QStyle::State_Selected.
    Last edited by marcel; 9th February 2008 at 17:15.

  2. The following user says thank you to marcel for this useful post:

    JeanC (9th February 2008)

Similar Threads

  1. Extract QStandardItemModel from QTableView
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2008, 09:34
  2. How to read CD with read?
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 29th June 2007, 09:20
  3. QIODevice read()
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 3rd May 2007, 01:29

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.