Results 1 to 10 of 10

Thread: Source code for createIndex() ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    120
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanked 42 Times in 41 Posts

    Default Re: Source code for createIndex() ?

    Qt Code:
    1. inline QModelIndex() : r(-1), c(-1), p(0), m(0) {}
    To copy to clipboard, switch view to plain text mode 
    This is the default constructor for a QModelIndex creating an invalid index. The implementation initializes internal members r, c, p and m to the values shown in () above.
    Qt Code:
    1. inline QModelIndex(const QModelIndex &other)
    2. : r(other.r), c(other.c), p(other.p), m(other.m) {}
    To copy to clipboard, switch view to plain text mode 
    This is the copy constructor creating a new QModelIndex as a copy of the existing QModelIndex other. The new index gets initialized with the internal state of the other object.

    In
    Qt Code:
    1. QModelIndex QAbstractTableModel::index(int row, int column, const QModelIndex &parent) const
    2. {
    3. return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex();
    4. }
    To copy to clipboard, switch view to plain text mode 
    method
    Qt Code:
    1. createIndex(int, int, int)
    To copy to clipboard, switch view to plain text mode 
    gets called with 3rd parameter set to 0. In the implementation of this method you will find a reinterpret_cast of the 3rd parameter to void pointer. From my understanding you need the 3rd parameter to create tree like structures (or even more sophisticated data structures). For plain tables I've never needed the 3rd createIndex() parameter.

    Best regards
    ars

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

    neuronet (26th December 2014)

Similar Threads

  1. Source code to *.ui
    By Zergi in forum Qt Tools
    Replies: 3
    Last Post: 28th September 2011, 18:12
  2. no source code
    By banlinhtienphong in forum General Programming
    Replies: 1
    Last Post: 25th July 2011, 17:19
  3. Source code
    By afflictedd2 in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2008, 09:04
  4. source code
    By Colx007 in forum Newbie
    Replies: 5
    Last Post: 19th December 2007, 09:15
  5. Qte source code
    By Gaurav vyas in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 1st July 2007, 14:11

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
  •  
Qt is a trademark of The Qt Company.