Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, November 2007
How to define additional roles?


Message 1 in thread

Hi!

Just subj. I have read in Qt assistant (Model Classes->Basic concepts) 
that it is possible to define additional roles for application-specific 
purposes.
Where I can read how to do it?

Thanks in advance.

Anton I Alferov

--
 [ signature omitted ] 

Message 2 in thread

On Friday 02 November 2007 12:31:16 Anton I Alferov wrote:
> Hi!
>
> Just subj. I have read in Qt assistant (Model Classes->Basic concepts)
> that it is possible to define additional roles for application-specific
> purposes.
> Where I can read how to do it?
Hi Anton,

Just put something like this in the header for your derived model class:

enum Roles
{
    MyItemTypeRole = Qt::UserRole + 1,
    MyOtherRole = Qt::UserRole + 2
};

etc. You can then use this in your class as you would any other role.

Hope this helps,

Sean

--
 [ signature omitted ]