Sections
Report typeSuggestion Status?Closed Resolution?Fixed
ProductQt Functional areaItemviews Version found4.0.1
Priority?3 Scheduled for?4.4.0

Description

QComboBox::setView/setModel should allow setting up a combobox that shows i.e. a QDirModel in a tree:

#include <QtGui>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QDirModel *model = new QDirModel;
    QTreeView *tree = new QTreeView;
    tree->setModel(model);

    QComboBox cb;
    cb.setView(tree);
    cb.setModel(model);

    cb.show();

    return app.exec();
}

This works, but is unusable as the popup a) is too small to show all contents (i.e. is scrolled horizontally so the (+) symbols are not visible), and b) it is impossible to open any branches, as QComboBox hides the popup when the mouse is pressed rather than when an item has been selected.

There are also other problems with regards to setting current item to an item with a valid parent.

---

There have been a handfull of improvements with this for 4.4, but it is still pretty basic.  You can now put a treeview in a combobox and the height will be calculated correctly and you can select items and the index will be correct.  In 4.5 the header is also added to the popup size.  So a simple tree with 1 column is useable in a combobox now.

An example of a useable treeview in a combobox (still can't expand though):
    view->header()->setStretchLastSection(true);
    view->header()->hide();
    view->expandAll();
    view->setItemsExpandable(false);
    view->setRootIsDecorated(false);

Feel free to request individual improvements to having treeview in a combobox.

History

2005-09-28 14:11 - Entry created
2005-10-03 10:11 - Priority changed to '3'
2005-10-03 10:11 - Version for fix set to '4.2.0'
2006-08-23 15:12 - Version for fix set to '4.2.1'
2006-09-04 14:32 - Version for fix set to '4.3.0'
2007-04-18 16:24 - Version for fix set to 'Some future release'
2007-05-03 10:55 - Version for fix set to '4.4.0'
2007-10-25 10:48 - Version for fix set to 'Some future release'
2008-04-15 14:30 - Version for fix set to '4.4.0'
2008-04-15 14:30 - Task status changed to 'Active'
2008-04-15 14:41 - Task status changed to 'Closed'
2008-04-15 14:41 - Resolution set to 'Fixed'

Patron of KDECustomers

Customers