Results 1 to 2 of 2

Thread: Can i share the same model for QtreeView and Qgraphics view......

  1. #1
    Join Date
    Jun 2011
    Posts
    7
    Qt products
    Qt3 Qt4

    Default Can i share the same model for QtreeView and Qgraphics view......

    Actually i want to draw network topology view on QGraphicsView ,for that i have one explorer treeview on the right side of the window ,both topology view and treeview should be in synk.so can i share the same model between both views?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: Can i share the same model for QtreeView and Qgraphics view......

    You cannot have common model for QTreeView and QGraphicsView, even though both of these are based on same concepts (Model/View), but the these use a different set of model interface classes.

    What you can do is, have a QTreeView connected to a QAbstractItemModel, and a QGraphicsView connected to QGraphicsScene, and then connect the QAbstractItemModel to QGraphicsView in the back-end. (You might have already figured this out, by now)

    The connection between QAbstractItemModel and QGraphicsView is responsible in keeping then in sync, so using signals & slot mechanism should be good, rather than a interface class.

    Also needless to mention you need use sub-class ofQAbstractItemMoel and sub-class of QGraphicsScen, as these base classes will not be sufficient to support the syncing functions

Similar Threads

  1. Replies: 1
    Last Post: 1st February 2010, 18:42
  2. Qgraphics View
    By amagdy.ibrahim in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2008, 10:10
  3. QTreeView with Model-View help
    By MathStuf in forum Qt Programming
    Replies: 10
    Last Post: 26th April 2008, 06:23
  4. Model/View Confusion in QTreeView - number of rows
    By themolecule in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 22:45
  5. QGraphics view problem
    By kiranraj in forum Qt Programming
    Replies: 5
    Last Post: 6th March 2007, 21:28

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.