Results 1 to 17 of 17

Thread: How to stop calling data() function for the child items in a tree view initially

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop calling data() function for the child items in a tree view initially

    The only function I have implemented in customized QSortFilterProxyModel is filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const.
    I have not implemented the data() function.

    What are the function I should to re implement while using proxy?

    Thanks in Advance.

  2. #2
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop calling data() function for the child items in a tree view initially

    I have implemented data() in proxy too, still same issue.



    Qt Code:
    1. QVariant proxy::data(const QModelIndex & proxy_index, int role) const
    2. {
    3. if ( ! index.isValid() )
    4. return QVariant();
    5.  
    6. QModelIndex source_index = mapToSource(proxy_index);
    7.  
    8. return QSortFilterProxyModel::data(proxy_index, role);
    9. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: How to stop calling data() function for the child items in a tree view initially

    Try minimizing your example instead of throwing in more and more code. Can you reproduce the issue with a bare standard item model and a bare QTreeView?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop calling data() function for the child items in a tree view initially

    When I tried using with QTreeView only, data function is calling as expected.

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

    Default Re: How to stop calling data() function for the child items in a tree view initially

    Quote Originally Posted by DURGAPRASAD NEELAM View Post
    When I tried using with QTreeView only, data function is calling as expected.
    So please show your customizations to the view.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop calling data() function for the child items in a tree view initially

    Below is the code for view. (there is lot of other c++ code in view, but typical qt related stuff in view is this much)

    Qt Code:
    1. MyView::MyView ( Model* treeModel) : QTreeView(parent)
    2. {
    3. setContextMenuPolicy( Qt::DefaultContextMenu );
    4. setSelectionMode( QAbstractItemView::ExtendedSelection );
    5. setSelectionBehavior( QAbstractItemView::SelectItems );
    6. installEventFilter( this );
    7.  
    8. m_proxyTreeModel = new ProxyModel( this ); // proxy model:
    9. m_proxyTreeModel->setSourceModel( m_treeModel ); // tree model created in viewer:
    10. m_proxyTreeModel->setDynamicSortFilter(true);
    11. setModel( m_proxyTreeModel );
    12.  
    13. setAllColumnsShowFocus( true );
    14. setUniformRowHeights( true );
    15. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: How to stop calling data() function for the child items in a tree view initially

    This is not your real code. This wouldn't even compile. Even if it did, it would crash when ran. And you were supposed to use a standard model against your custom view. Without any proxy models inbetween.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 14th March 2013, 22:50
  2. tree view displaying widgets as items
    By paksas in forum Qt Programming
    Replies: 9
    Last Post: 28th January 2013, 13:58
  3. Replies: 5
    Last Post: 17th February 2009, 04:35
  4. [QThread] Function calling after thread.stop()
    By Macok in forum Qt Programming
    Replies: 4
    Last Post: 7th February 2009, 13:33
  5. How did I disable auto-scrolling function in tree-view
    By alfa_wu in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2007, 08:31

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.