Results 1 to 2 of 2

Thread: what is QComboBox::rootModelIndex?

  1. #1
    Join Date
    Jun 2010
    Location
    Cincinnati, Ohio, USA
    Posts
    92
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default what is QComboBox::rootModelIndex?

    What is QComboBox::rootModelIndex? I searched the web and cannot find anything, I even searched through the Qt source and only found one reference to it in the qfiledialog.cpp, but it makes little sense. Can anyone enlighten me?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: what is QComboBox::rootModelIndex?

    You need it when working with a tree model. Compare:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5.  
    6. QApplication app(argc, argv);
    7.  
    8. QStandardItem *parentItem = model.invisibleRootItem();
    9. for (int i = 0; i < 5; ++i)
    10. {
    11. QStandardItem *item = new QStandardItem(QString("Root %1").arg(i));
    12. for (int j = 0; j < 5; ++j)
    13. {
    14. QStandardItem *itemSub = new QStandardItem(QString("%1:%2").arg(i).arg(j));
    15. item->appendRow(itemSub);
    16. }
    17. parentItem->appendRow(item);
    18. }
    19.  
    20. b.setModel(&model);
    21. b.show();
    22.  
    23. b2.setModel(&model);
    24. b2.setRootModelIndex(model.index(1,0));
    25. b2.show();
    26.  
    27. return app.exec();
    28. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qcombobox
    By Project25 in forum Qt Programming
    Replies: 2
    Last Post: 16th December 2009, 19:29
  2. QComboBox
    By bismitapadhy in forum Qt Programming
    Replies: 7
    Last Post: 15th July 2009, 06:01
  3. QComboBox
    By coderbob in forum Qt Programming
    Replies: 4
    Last Post: 12th December 2007, 06:38
  4. QComboBox
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 31st August 2007, 13:17
  5. QComboBox??
    By crocus in forum Qt Programming
    Replies: 3
    Last Post: 8th February 2006, 18:00

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.