Results 1 to 4 of 4

Thread: QTreeview/Model and signals

  1. #1
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default QTreeview/Model and signals

    I am trying to respond to dblclicks in a Qtreeview derived class with a QAbstractItemModel derived model behind it.

    The dblclick event is captured in treeview and gives me an index into the tree.
    But all the information to decode what the particular entry is, and how to respond to a dblclick is in treemodel.

    Is there a way of accessing the model from the view - there doesn't seem to be a getModel() function.

    Or should I re-emit the dblclick signal to a slot in the treemodel, passing on the index, and then let the treemodel send the appropriate signal to my app?

    Thanks

  2. #2
    Join Date
    Mar 2008
    Posts
    16
    Thanks
    3
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: QTreeview/Model and signals

    If you have implemented your own model, you can access to it from QTreeView by using QAbstractItemModel * QAbstractItemView::model () const

  3. The following user says thank you to foxyproxy for this useful post:

    mgb_qt (31st March 2010)

  4. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTreeview/Model and signals

    Then you have to cast it eventually. That's no problem, but somewhere you create the model and set it to the view, so just store that pointer to a local member and you can access it everywhere very easy.

  5. #4
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: QTreeview/Model and signals

    Thanks, somehow I missed that in the docs

    I used to use the setBlah() / blah() naming for getters and setters but my new company standard is get/set so I was looking for the wrong thing.

Similar Threads

  1. QTreeView expand signals
    By Vidar Bøe in forum Qt Programming
    Replies: 2
    Last Post: 26th May 2008, 10:47
  2. QTreeView with Model-View help
    By MathStuf in forum Qt Programming
    Replies: 10
    Last Post: 26th April 2008, 07:23
  3. Replies: 5
    Last Post: 16th May 2007, 12:03
  4. using QTreeView with a Database model
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 00:29
  5. Model/View Programming -- Signals
    By KjellKod in forum Qt Programming
    Replies: 17
    Last Post: 7th February 2006, 17:36

Tags for this Thread

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.