Results 1 to 2 of 2

Thread: QFileSystemModel + UserRole

  1. #1
    Join Date
    Dec 2014
    Posts
    49
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Windows

    Default QFileSystemModel + UserRole

    so i have been playing with this for an hour or two, and done some googling on it, but am looking for confirmation.

    Is it possible to use Qt::UserRole with QFileSystemModel, every time i try to set a value to it, i get a false back, and querying that role for data returns an invalid variant.

    Thanks much

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QFileSystemModel + UserRole

    I don't think the QFileSystemModel has any built-in support for the Qt::UserRole. The general idea of that role is that it (and roles with higher values - UserRole + 1, etc.) are for your use in custom models. So if you want to store something in model that will be accessed by Qt::UserRole, you will have to derive a model from QFileSystemModel, add data structure support for whatever you want to store, and then implement data() and setData() to return the appropriate QVariant for Qt::UserRole. For all other roles, you can simply call the base class implementation.

Similar Threads

  1. QFileSystemModel and QML
    By enrico5th in forum Qt Quick
    Replies: 5
    Last Post: 18th June 2014, 15:23
  2. Using Qt::UserRole in the Model/View architecture
    By d_stranz in forum Qt Programming
    Replies: 8
    Last Post: 23rd January 2011, 16:13
  3. Replies: 3
    Last Post: 6th October 2010, 16:11
  4. Model/View one index.column as hidden UserRole
    By doitux in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2008, 12:08
  5. setting UserRole data in QSqlTableModel
    By orgads in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2008, 09:40

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.