[PyKDE] QTable programmatic selection

Ruth Wright rwright at envisage-inc.com
Fri Apr 12 18:24:40 BST 2002


I'm probably just being dense, but I cannot figure out how to
programmatically set the selection of a table. I have a table in one
window, and I'm trying to create a new window which is a copy of the old
one. I'd like to have anything selected in the original window be
selected in the new one. 
I'm running on linux, with pyqt version 3.1

My table is an 11 column table and is set with a selectionMode of 
QTable.SingleRow

Here's what I've done:
(I'm using PyQt, so pure Qt users bear with me)
After checking that something is indeed selected,
I get the current selection of the original table using:  
    orig_selection = OrigTable.selection(OrigTable.currentSelection());
    row = orig_selection.anchorRow();
This seems to be ok, since the row value it is gettings seems to match
what I would expect. 
I then create a QTableSelection and set it using:
   new_selection = QTableSelection();
   new_selection.init(row,0);
   new_selection.expandTo(row,10); 
new_selection.isActive() here is returning a 1
   ret_val = NewTable.addSelection(newSelection);
ret_val gets set here to 0
NewTable.currentSelection() returns a -1
test_selection = NewTable.selection(ret_val) seems valid
test_selection.anchorRow() returns the same row as my original "row"
value.

Is there anything fundamentally wrong with this? Is it not possible to
set a selection so that currentSelection() will return something?

I'd appreciate any pointers!






Ruth Wright
Envisage Inc.






More information about the PyQt mailing list