Results 1 to 1 of 1

Thread: how to set row in QListView before showing?

  1. #1
    Join Date
    Mar 2011
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: how to set row in QListView before showing?

    Hi folks!

    I use QListView to show an Address Book (Name, Surname, Phone1, Phone2 etc). As a pattern I use this example (because I'm really new in QT):
    http://qt-articles.blogspot.com/2010...-qt-using.html

    The resulted GUI looks like at my Nokia phone but I want to go further and set a preselected row before the QListView is displayed. When I used QListWidget it had a very good function setCurrentRow(int). For this QListView I need the same function and don't know how implement this (two day of searching..)

    please advise


    Added after 20 minutes:


    Solved by the following code:

    QModelIndex i = ui->aBookContact->model()->index(row_to_select, 0);
    ui->aBookContact->selectionModel()->setCurrentIndex(i, QItemSelectionModel::SelectCurrent);
    Last edited by lisarden; 29th March 2011 at 15:38.

  2. The following user says thank you to lisarden for this useful post:

    Goddard (24th August 2012)

Similar Threads

  1. QWizard not showing
    By Ossi in forum Newbie
    Replies: 5
    Last Post: 11th May 2011, 05:25
  2. QListView not showing all items in the model
    By mclark in forum Qt Programming
    Replies: 13
    Last Post: 2nd September 2010, 21:07
  3. Showing form - help
    By waynew in forum Newbie
    Replies: 3
    Last Post: 28th October 2009, 01:04
  4. QListView is not showing contnet
    By hrudhay in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 21st August 2008, 07:31
  5. Showing QMainWindow without showing a child QWidget
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 4th March 2007, 09:03

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.