Results 1 to 6 of 6

Thread: Select a row from QTreeView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Select a row from QTreeView

    I have a QTreeView with the model set from a QSqlQueryModel.
    Now I need to select the first row when the query is run.
    I can't find any way to do this programatically.
    QTreeWidget has setCurrentItem() and some other means, but QTreeView and QSqlQueryModel don't seem to have any methods for selection. Do I have to resort to using a QTreeWidget ?

    BTW: Found this in the docs, but it doesn't select anything:
    Qt Code:
    1. QModelIndex first = model->index(0, 0, QModelIndex());
    2. treeView->setCurrentIndex(first);
    To copy to clipboard, switch view to plain text mode 
    Last edited by vieraci; 10th July 2009 at 05:22. Reason: updated contents

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.