Results 1 to 2 of 2

Thread: Model's flags method

  1. #1
    Join Date
    May 2013
    Location
    Georgia,Tbilisi
    Posts
    32
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Model's flags method

    Hi. I'm reading official Qt documentation and I can't understant piece of code:
    Qt Code:
    1. //! [quoting mymodel_f]
    2. Qt::ItemFlags MyModel::flags(const QModelIndex &index) const
    3. {
    4. return Qt::ItemIsEditable | QAbstractTableModel::flags(index);
    5. }
    6. //! [quoting mymodel_f]
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. Qt::ItemIsEditable | QAbstractTableModel::flags(index);
    To copy to clipboard, switch view to plain text mode 

    Why we can't just return Qt::ItemIsEditable?

  2. #2
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Model's flags method

    The default implementation returns "Qt::ItemIsSelectable|Qt::ItemIsEnabled" for valid indexes (see qabstractitemmodel.cpp).
    If you want to return these default flags in your custom implementation you might want to call the default implementation as shown in your piece of code. If not simply return the flags you need.

  3. The following user says thank you to Infinity for this useful post:

    Higgs (12th September 2014)

Similar Threads

  1. About the Flags
    By rezas1000 in forum Newbie
    Replies: 1
    Last Post: 17th August 2014, 16:38
  2. Replies: 1
    Last Post: 29th August 2013, 05:41
  3. QMAKE FLAGS in qmake.conf for solaris-cc-64 uses old flags
    By qmake_query in forum Installation and Deployment
    Replies: 0
    Last Post: 16th October 2012, 09:11
  4. Replies: 1
    Last Post: 25th November 2010, 11:37
  5. Flags of a list model
    By woodtluk in forum Qt Programming
    Replies: 4
    Last Post: 8th October 2010, 11:45

Tags for this Thread

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.