Important: Please read the Qt Code of Conduct -

Table & tree widgets and their flexibility

  • I am new to Qt, having written GUIs only in Java Swing (and Java AWT before that).

    I am considering using Qt for a desktop application that has the requirement of displaying a multi-column tree widget such that one column displays an icon, and when clicked, that icon changes, allowing the user to cycle through several options.

    My first question is simply which widget do I use for multi-column trees?: tree widget, table widget, or something else. The second is whether the above described behavior is possible under Qt.

    Thank you.

  • You would probably have a hard time doing this in Qt, but this is possible. Check "QTreeView":

  • In Qt:
    QTreeWidget is for relatively little dataset.
    If you have large dataset you should use QTreeView (this is an MVC approach).

  • I definitely would want the MVC approach.

    As beemaster says the changing icons is difficult but possible, can someone please provide more information, including a code snippet if one is available? This would help greatly.

  • The Qt directory has an Example directory, try to search there after the QTreeView (c:\Qt\4.8.3\examples.. or similar).

  • Not all that hard at all. You'd use a QTreeView on a custom QAbstractItemModel derived model. For the cycling through the icons, you might either use a custom delegate, or use the clicked signal and modify the model outside of the model/view context.
    Getting a tree model right is tricky, but what you want to achieve is certainly possible.

Log in to reply