Important: Please read the Qt Code of Conduct -

How to add Combobox at the top of treeview

  • Hi All

    I want to add the combobox at the top of tree view and depending upon the selection of the items from that combobox
    I want to show different treeviews how to do this?

  • One way is to use a [[doc:QStackedWidget]], and create a page with a QTreeView for each of the items in your combobox. Then, let the selectedIndex of the combobox determine the currentIndex() of the widget stack.

    Or, if it really is the model in the view you'd like to change, do exactly that: use a single QTreeView, and simply add a bit of code to change the model you're using for the view based on the selected item in the combo box.

Log in to reply