Results 1 to 6 of 6

Thread: Select a row from QTreeView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2015
    Posts
    4

    Default Re: Select a row from QTreeView

    Qt Code:
    1. QPoint p(0,27 * [RowNumber]);
    2. ui->tree_Widget->setCurrentIndex(ui->tree_Widget->indexAt(p));
    To copy to clipboard, switch view to plain text mode 

    You can use this. Its not perfect, but it works. Maybe you have to change the 27.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,349
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Select a row from QTreeView

    You can use this. Its not perfect, but it works. Maybe you have to change the 27.
    Sorry, but that is not a good answer. It depends on font size, row height, and any number of other variables unique to the PC where the app is running. On your PC, maybe the height of a row is 27, but on my PC, it probably isn't. The "indexAt( const QPoint & )" method is generally used to let the application know where a user clicked with the mouse, not in the way you are suggesting.

    The answer in the original post is correct and should be used.

Similar Threads

  1. QTreeView Problem
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 7th March 2009, 10:32
  2. QTreeView help
    By bepaald in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 21:22
  3. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  4. Selection problem in QTreeView
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 7th October 2006, 16:02
  5. QSortFilterProxyModel & QTreeView
    By Bear in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 15:04

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.