Results 1 to 12 of 12

Thread: GraphicsView / ModelView Integration ???

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default GraphicsView / ModelView Integration ???

    Hi all,

    Abstract:
    • I'm working on implementing/emulating this modular data exploration platform concept/functionality in Qt4.
    • I tend to want to use the excellent Model/View framework as the core of all my data-centric applications.
    • The Graphics View Framework is exciting and I'm still learning it.
    • I see aspects of both Model/View and Graphics/View being needed for this to work for me.
      • Model/View as the interface to flexible and diverse back-end for my data items.
      • Graphics/View for the node/edge visual representation.
    • I searched through relevant threads here on the forum without finding many clues to answer my questions.

    Questions:
    • First, I have always wondered why the Graphics View Framework isn't integrated with the Model View Framework? This would seem very logical to me.
    • Since I need "edge" connectors between the graphical representation of my nodes, it seems this would require the Graphics View Framework... Is this correct?
    • Can edges be drawn in Model/View alone?
    • Can I use the Graphics/View as the front-end, and Model/View as the back-end interface in my application?
    • Do you have any other comments or recommendations for me?

    Thank you for your comments,
    -travlr
    Last edited by travlr; 7th February 2008 at 20:08.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: GraphicsView / ModelView Integration ???

    Quote Originally Posted by travlr View Post
    First, I have always wondered why the Graphics View Framework isn't integrated with the Model View Framework? This would seem very logical to me.
    I was asking myself the same question but at some point in time I stopped doing it - the architectures are just too different. Of course if you want to provide a model based access to the graphics view framework, it is possible and I even had plans to do it but never managed to start working on it.

    Since I need "edge" connectors between the graphical representation of my nodes, it seems this would require the Graphics View Framework... Is this correct?
    No, it's not required but it would simplify things a bit.

    Can edges be drawn in Model/View alone?
    Yes, you can draw anything you like if you use a custom view.

    Can I use the Graphics/View as the front-end, and Model/View as the back-end interface in my application?
    In theory - yes. In practice - hard to say at that stage, probably yes.

    Do you have any other comments or recommendations for me?
    Start with simple things (omit the model-view framework) and once you have it going with the graphics view, add more complexity (including the mvc component).

    Good luck

  3. #3
    Join Date
    Feb 2007
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: GraphicsView / ModelView Integration ???

    Hi Wysota,

    Thank you very much for your reply.

    Start with simple things (omit the model-view framework) and once you have it going with the graphics view, add more complexity (including the mvc component).
    I do have a working, preliminary graphicsview model. At this point I'm ready to implement the data item back-end. What I would like to do is utilize the QAbstractItemModel, but I guess you are recommending I implement my own MVC framework for the hierarchical back-end interface.

    Is that correct? Would you add a little more specificity for me? I'm still learning.

    Thank you kindly,
    -travlr
    Last edited by travlr; 7th February 2008 at 20:52.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: GraphicsView / ModelView Integration ???

    Quote Originally Posted by travlr View Post
    . What I would like to do is utilize the QAbstractItemModel, but I guess you are recommending I implement my own MVC framework.

    Is that correct?
    No, it's not. You have to subclass QAbstractItemModel and wrap it around QGraphicsScene.

  5. The following user says thank you to wysota for this useful post:

    travlr (7th February 2008)

  6. #5
    Join Date
    Feb 2007
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: GraphicsView / ModelView Integration ???

    Yes, ok. I sort of see it now. So are you saying QAbstractItemView is not needed, because the QGraphicsScene is, in essence, the "model" to the QGraphicsView? I'll start working on this. Thank you very much.
    Last edited by travlr; 7th February 2008 at 21:24.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: GraphicsView / ModelView Integration ???

    Quote Originally Posted by travlr View Post
    So are you saying QAbstractItemView is not needed, because the QGraphicsScene is, in essence, the "model" to the QGraphicsView?
    QGraphicsScene is a model for QGraphicsView. Just think if you need the model-view for something else, because if not, there is no point in implementing a model for the scene. In my case I wanted to show the object hierarchy using QTreeView and QGraphicsView at the same time, so I had no other choice but to implement a QAbstractItemModel subclass.

  8. #7
    Join Date
    Feb 2007
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: GraphicsView / ModelView Integration ???

    Quote Originally Posted by wysota View Post
    QGraphicsScene is a model for QGraphicsView. Just think if you need the model-view for something else, because if not, there is no point in implementing a model for the scene. In my case I wanted to show the object hierarchy using QTreeView and QGraphicsView at the same time, so I had no other choice but to implement a QAbstractItemModel subclass.
    Yes, that's my intention too. I want to have a singular QAbstractItemModel interface to a multiplicity of views, including QAbstractItemView based views and the QGraphicsView. Which is why it kinda bothers me that its not naturally integrated already.
    Last edited by travlr; 7th February 2008 at 21:57.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: GraphicsView / ModelView Integration ???

    Quote Originally Posted by travlr View Post
    Which is why it kinda bothers me that its not naturally integrated already.
    I think it would limit the GraphicsView framework too much.

  10. #9
    Join Date
    Feb 2007
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: GraphicsView / ModelView Integration ???

    Quote Originally Posted by wysota View Post
    I think it would limit the GraphicsView framework too much.
    Well I'm definitely not familiar enough yet, but agree that there are most probably un-welcome limitations.

    Just as you (have) and I (am trying to) implement an interface... I don't see the reason yet, why one isn't provided for such a natural, symbiotic relationship.

    Come to think of it, though maybe not practical as is, I believe a Model/View architecture should be at the Qt core itself. ...Everything in life thats not, in some way, a portrayal of chaos... is in a natural hierarchical topology/taxonomy. This holds especially true in computer science, me thinks.
    Last edited by travlr; 7th February 2008 at 23:13.

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: GraphicsView / ModelView Integration ???

    Quote Originally Posted by travlr View Post
    Come to think of it, though maybe not practical as is, I believe a Model/View architecture should be at the Qt core itself.
    Funny... Andreas Hanssen (vel Bitto) thinks the same way about QGraphicsView

  12. #11
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: GraphicsView / ModelView Integration ???

    Graphics view and Model/View are conceptually similar, but implemented very differently. However, there is no reason you cannot write a QAbstractIemView that uses QGraphicsScene/View for visualization. It would be a considerable effort, but the results could be very nice.

    Alternatively, since QAbstractItemModel is merely a wrapper around the underlying data, you can always have the QGraphicsScene access that data directly, bypassing model/view.

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
  •  
Qt is a trademark of The Qt Company.