Results 1 to 5 of 5

Thread: can't do a QTreeView with a QStandardItemModel

  1. #1
    Join Date
    Apr 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy can't do a QTreeView with a QStandardItemModel

    I'm trying to do a QTreeView but I cannot make childs.

    my code to fill in the model is:
    void FactoryJob:rocesaTrabajo()
    {
    qDebug() << "procesaTRabajo";
    QModelIndex parent = QModelIndex();
    m_model->insertRows(0,1,parent);
    QModelIndex indexA = m_model->index(0, 0,parent);
    m_model->setData(indexA, "hola");

    m_model->insertRows(0,1,indexA);
    QModelIndex indexB = m_model->index(0, 0, indexA);
    m_model->setData(indexB, "jaja");

    m_model->insertRows(1,1,parent);
    QModelIndex indexC = m_model->index(1, 0,parent);
    m_model->setData(indexC, "adios");

    update();

    }

    And my view only show the indexA and indexC without the [+] and if I ask hasChildren(indexA) the answer is false...

    What am I doing wrong?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: can't do a QTreeView with a QStandardItemModel

    Maybe you also need to insertColumns() ?

  3. #3
    Join Date
    Apr 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: can't do a QTreeView with a QStandardItemModel

    no because I do it before. My problem is I don't see the children indexB but I can see the parents indexA and indexC.

    Any others idea?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: can't do a QTreeView with a QStandardItemModel

    Quote Originally Posted by Nuria
    no because I do it before.
    Are you sure you did that with "indexA" as a parent too?

    Try:
    Qt Code:
    1. m_model->insertRows(0,1,indexA);
    2. m_model->insertColumns(0,1,indexA);
    3. QModelIndex indexB = m_model->index(0, 0, indexA);
    4. m_model->setData(indexB, "jaja");
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Apr 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: can't do a QTreeView with a QStandardItemModel

    thanks. I solve my problem adding the column

Similar Threads

  1. QTreeView repaint
    By graeme in forum Qt Programming
    Replies: 17
    Last Post: 13th March 2012, 13:27
  2. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24
  3. [QT4 & XP] QTreeView issue with Designer form
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 2nd March 2006, 17:42
  4. QSortFilterProxyModel & QTreeView
    By Bear in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 15:04
  5. How to dispay an icon in the first column of QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 1
    Last Post: 5th January 2006, 15:51

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.