473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

PyQt4: How to select ListView item programmatically?

I have a list view with few items, and I want to select, for example, first item (from code)! Very simple, but... QListView haven't something like "selectItem(index)" (like QTableView has "selectRow(index)")!? Very strange!

I tried everything, but can't figured how this works with Views and Models!? Can somebody, please, help me, and write simple example how to do that?

I working with my class ListModel, which is derived from QtCore.QAbstractListModel... I redefined methods rowCount, data, setAllData and flags! I now that I must use QListView's method setSelection (self, QRect, QItemSelectionModel.SelectionFlags), but I can't figured how to define QItemSelectionModel.SelectionFlags?

Please help me with some example?

Thanks in advance!

Kind regards!
Feb 12 '10 #1
2 8148
Anyone who can help, please?
Feb 15 '10 #2
Expand|Select|Wrap|Line Numbers
  1. ix = self.list.model().index(whichrow you want to selct, 0)
  2. self.list.selectionModel().setCurrentIndex(ix,QtGui.QItemSelectionModel.SelectCurrent)
Mar 22 '19 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Richard | last post by:
>-----Original Message----- > before the listview is displayed The BEFORE DISPLAYED might be your problem. As a guess I'd try moving the code to the form's "OnVisibilityChanged" handler: if...
2
by: Aaron Queenan | last post by:
Is there any way to know whether the OnItemCheck is being called in response to a user action (mouse or keyboard) as opposed to the form loading? I have a class which derives from...
5
by: Richard Bond | last post by:
I'm having a lot of trouble programatically selecting a listview item. How do you do this? These didn't work for me in the context of the sub below (that's trying to move up an Item in the...
1
by: Shane | last post by:
I have a text box select items in a listview as text is being typed into the text box. I get the select bar to move correctly in the Listview control. If the user presses the down or up key in...
4
by: Joerg Trumpfheller | last post by:
Hey folks, I have a problem with selecting an item in a listview control from outside. Listview items are binded with unique ids. I got now an id from another control and want to select the...
3
by: rlg | last post by:
We have C# 2005 multi-threaded app. A background thread is processing data and periodically updating the contents of a ListView. Sometimes, the user clicking on a ListView item will not select...
5
by: Phill W. | last post by:
(VB'2003) What's the correct way to remove multiple, selected items from a ListView control (say, from a ContextMenu)? I ask because I'm getting a very annoying ArgumentOutOfRangeException...
3
by: Skink | last post by:
Hi, I created simple property classes with editing option, but since i'm not too much experienced in PyQt4 i'd like to ask if i handle ColorProperty changing right. Any other Property has its...
2
by: Rich Raffenetti | last post by:
In the listview control I can set the highlighted item with listview.focus() listview.items(integerValue).selected=true How do I programmatically scroll the pane of the details view to bring...
0
by: =?Utf-8?B?SWdvcg==?= | last post by:
Hi everyone! I have some strange behavior of ListView control in WPF. We are developing application in C#. I created ListView with some items and set SelectedIndex to some index in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.