Results 1 to 3 of 3

Thread: Multible QCombobox tree with model view

  1. #1
    Join Date
    Sep 2010
    Location
    Norway
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Multible QCombobox tree with model view

    Hi

    I have a simple tree that i want to present in QCombobox:

    A
    -a
    -b
    -c
    B
    -e
    -f
    C

    model-view.jpg

    When selecting A in the first combobox, I want to populate the children A (a, b, c) in the second combox. I have used the qt example simpletreemodel. I tryed to fidle with the QDataWidgetMapper without anny success. What is the right way too go here (qt way)?

    Anny good ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Multible QCombobox tree with model view

    QComboBox::setModel(your model)
    QComboBox::setRootModelIndex(index of the first combobox)

  3. #3
    Join Date
    Sep 2010
    Location
    Norway
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Multible QCombobox tree with model view

    thanks...


    void ComboBoxTreeView::updateRootModelIndex()
    {
    if(m_model == 0)
    return;
    int size = m_group->count();
    for(int i = 0; i < size;i++)
    {
    QComboBox* box = m_group->getComboBox(i);
    if(i > 0)
    {
    QComboBox *parent = m_group->getComboBox(i-1);
    if(parent->isWidgetType())
    {
    QModelIndex pindex = parent->rootModelIndex();
    box->setRootModelIndex(pindex.child(parent->currentIndex(),0));
    }
    }
    else if(i == 0)
    {
    box->setRootModelIndex(m_model->index(0,0));
    }
    }
    }

Similar Threads

  1. Replies: 33
    Last Post: 7th December 2009, 10:11
  2. How to map tree model data to list view
    By msopanen in forum Qt Programming
    Replies: 0
    Last Post: 10th November 2009, 19:56
  3. how to update a tree view model
    By chow in forum Qt Programming
    Replies: 8
    Last Post: 26th March 2009, 15:27
  4. How use Model view with a tree wich have Cycle ?
    By weepdoo in forum Qt Programming
    Replies: 2
    Last Post: 9th December 2008, 17:05
  5. data, model and tree view
    By larry104 in forum Qt Programming
    Replies: 17
    Last Post: 3rd July 2006, 14:43

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.