Results 1 to 3 of 3

Thread: How to find which column clicked from a treeview.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to find which column clicked from a treeview.

    Hello

    I have created a QStandardItemModel with * rows and 6 columns in each row to pass on a treeview.
    I need to use the slot below to do various things ,but ONLY if the second column has clicked in the treeview.If it is any other column just nothing happens, or at least the program enters doThings() function but does a check inside to see what column from the 6 had clicked.If it is the 2nd continues, else breaks.Can someone help me with this check?

    (this is the slot:doThings( const QModelIndex& ))

    Thanks!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to find which column clicked from a treeview.

    try to catch
    Qt Code:
    1. QHeaderView::sectionClicked ( int logicalIndex )
    To copy to clipboard, switch view to plain text mode 
    but this signal emits only when header section was clicked.

    if you need to determinate column by clicking on item, you can catch
    Qt Code:
    1. void QAbstractItemView::clicked ( const QModelIndex & index )
    To copy to clipboard, switch view to plain text mode 

    and
    Qt Code:
    1. index.column()
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to find which column clicked from a treeview.

    correct..thanks man!

Similar Threads

  1. problems installing Qt opensource with msvc2008 support
    By odin1985 in forum Installation and Deployment
    Replies: 6
    Last Post: 24th May 2008, 10:06
  2. Replies: 0
    Last Post: 10th November 2006, 14:46
  3. Replies: 17
    Last Post: 31st March 2006, 06:57

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.