Results 1 to 10 of 10

Thread: How to set selected item of a QListWidget?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set selected item of a QListWidget?

    ok so, QListWidget inherits QListView..QListView inherits QAbstractItemView which is the base class of all views..QAbstractItemView provides many functions that'll allow u modify your view at the basic level..u can do what u want in a number of ways.

    Qt Code:
    1. QListWidget *list = new QListWidget();
    2. list->setSelectionMode(QAbstractItemView::SingleSelection);
    3.  
    4. QModelIndex modelIndex = list->rootIndex(); // u have to find the model index of the first item here
    5. list->setCurrentIndex(modelIndex);
    To copy to clipboard, switch view to plain text mode 

    before going further ahead, give a read to http://doc.trolltech.com/4.4/model-v...roduction.html just an hour of reading this will give u a lot of information about mvc in qt

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

    Lawand (5th April 2009)

Similar Threads

  1. How to get parent of selected item in TreeView?
    By RavenS in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2009, 13:27
  2. Changing selected item color in non-current window.
    By Doug Broadwell in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2007, 07:09
  3. QTreeView: selection behavior upon selected item removal
    By Pieter from Belgium in forum Qt Programming
    Replies: 6
    Last Post: 11th July 2007, 16:00
  4. Replies: 1
    Last Post: 19th April 2007, 22:23
  5. keypress while editing an item in QListWidget
    By Beluvius in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 09:56

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
  •  
Qt is a trademark of The Qt Company.