Results 1 to 3 of 3

Thread: QCompleter for tree model showing only leaves/children

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2015
    Thanked 1 Time in 1 Post
    Qt products
    MacOS X Windows

    Default QCompleter for tree model showing only leaves/children

    I have a project where I have multiple QComboboxes that I need a QCompleter for. There is a main QCombobox (let's call it parentCombobox) and then there are multiple QComboxes (childComboboxes) whose lists/completions are affected by what is selected in parentCombobox. The data is stored in a tree model using QAbstractItemModl.

    To give a simple food-based example of what I am looking for, let's say that the user selected "Breakfast" in rootCombobox(Meal), then I would like the list in childCombobox1(Protein) to show "eggs", "sausage", "bacon", etc and the list in childCombobox2(Carb) to show "toast", "hash browns", etc. If the user selected "Lunch" from the rootCombobox instead, the lists in the childComboboxes would change to proteins and carbs appropriate to that mealtime. The data would be stored in a model that looks like so:
    | |_Protein
    | | |_Eggs
    | | |_Sausage
    | | |_Bacon
    | |_Carbs
    | | |_Toast
    | | |_Hash Browns
    | |_Protein
    | | |_Sliced Turkey
    | | |_Sliced Ham
    | |_Carbs
    | | |_Bread
    | | |_Chips

    And so on and so forth. I have reviewed this example: but my problem is that there are no separators because it's not a file system and user would not be typing in a full path to separate. Is there a way I can achieve what I am looking for by subclassing QCompleter as in the example, or do I need to simply get QStringLists of the leaves in the tree and pass them to individual QCompleters for the comboboxes?

    Maybe something that involves using the pathFromIndex function ( ) to create a full path behind the scenes where one doesn't actually exist?
    Last edited by ce_nort; 15th June 2019 at 23:05.

Similar Threads

  1. Replies: 1
    Last Post: 29th August 2013, 05:41
  2. Replies: 0
    Last Post: 5th September 2011, 08:08
  3. disable a parent and children in a tree model
    By qt_gotcha in forum Newbie
    Replies: 4
    Last Post: 9th July 2009, 06:49
  4. Help on adding children to tree view
    By vieraci in forum Qt Programming
    Replies: 3
    Last Post: 5th June 2009, 07:54
  5. Replies: 1
    Last Post: 12th October 2008, 08:21

Tags for this Thread


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.