Results 1 to 3 of 3

Thread: Hierarchical Chart

  1. #1
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Hierarchical Chart

    Hi,
    I'm trying to create a chart like the following one, where I can expand/contrat horizontal lines:


    My idea is to implement the chart by a customized qtreeview...
    You have some other idea?
    Last edited by fruzzo; 2nd May 2011 at 14:45.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Hierarchical Chart

    My idea is to implement the chart by a customized qtreeview...
    You can probably get that to work, but it wouldn't be easy. QTreeView has protected virtual methods drawRow(), and drawBranches() that you could override to draw the bars and connectors. You would need a column in your tree model for every day in the Gantt chart.

    QTreeView and the QAbstractItemModel it uses are designed to handle simple hierarchies where only column 0 of each row is allowed to have children. Is that how Gantt chart dependencies work? What happens for the case where you have a task that depends on two or more earlier tasks (that is Task3 cannot be started until Task1 and Task2 are both done)? I don't think you can display that in a QTreeView, although a customized QAbstractItemModel can handle almost any kind of graph-structured data.

    You might be better off if you started with QAbstractItemView and QAbstractItemModel and wrote the drawing code yourself instead of try to hack away at QTreeView.

    Edit: I think in graph-theory terms, the dependencies in a Gantt chart are modeled as a "directed acyclic graph" (DAG). It is "directed" in that the dependencies flow in one direction only (a later task can depend only on earlier ones) and "acyclic" in that there can't be any loops (which would mean an earlier task couldn't start until a later task was finished, which is impossible unless you have a time machine). There are lots of algorithms out there for manipulating DAGs, including such useful things as finding the shortest path between two nodes (which tells you the minimum time required to complete Task B starting at Task A), determining whether there are cycles (which aren't allowed in a Gantt chart), etc.
    Last edited by d_stranz; 3rd May 2011 at 03:56.

  3. #3
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Hierarchical Chart

    Thanks for the suggestion...however I don't need of a Gantt chart but something that look like it...My work is simplified by absence of connectors, I have to draw only bars mapped over a timeline (h:m:s) without a subdivision in days so I haven't the requirement one column for every day.

Similar Threads

  1. Searching a hierarchical QStandardItemModel
    By Zoober7 in forum Qt Programming
    Replies: 5
    Last Post: 21st June 2013, 09:45
  2. Hierarchical TreeView
    By cia.michele in forum Qt-based Software
    Replies: 0
    Last Post: 18th April 2011, 08:08
  3. Hierarchical QTableView
    By lotek in forum Newbie
    Replies: 0
    Last Post: 12th January 2011, 19:24
  4. Hierarchical Table/Listview
    By cia.michele in forum Qt Programming
    Replies: 8
    Last Post: 7th December 2009, 08:50
  5. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17

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.