Results 1 to 3 of 3

Thread: how to get qstandarditem from qmodelindex using qitemdelegate (qabstractitemmodel)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2015
    Posts
    12
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default how to get qstandarditem from qmodelindex using qitemdelegate (qabstractitemmodel)

    I have a qstandarditemmodel and a qtableview but when using QItemDelegate to get QLineEdit editor I must declare QAbstractItemModel rather than QStandardItemModel when using Delegate::setModelData, thus I cannot use QstandardItem::itemFromIndex within the setModelData function of the delegate.

    How can I get a QStandardItem from a QmodelIndex in this case?

    Or how can I use the delegate with QStandardItemModel rather than QAbstractItemModel so that I can access model->itemFromIndex...


    Qt Code:
    1. void Delegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
    2. {
    3.  
    4.  
    5. QStandardItem *item = model->itemFromIndex(index); //itemFromIndex does not exist in this context!
    To copy to clipboard, switch view to plain text mode 
    Last edited by qsurvae; 1st July 2015 at 12:01.

Similar Threads

  1. Replies: 3
    Last Post: 21st June 2011, 06:25
  2. getting data & QModelIndex
    By alexandernst in forum Newbie
    Replies: 3
    Last Post: 6th August 2009, 19:43
  3. Problem with QModelIndex
    By Kesy in forum Qt Programming
    Replies: 6
    Last Post: 30th October 2008, 08:44
  4. QModelIndex problem!
    By landonmkelsey in forum Qt Programming
    Replies: 10
    Last Post: 28th August 2008, 19:46
  5. Replies: 3
    Last Post: 7th May 2006, 17:07

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.