[Qt-jambi-interest] Manual Selection in QTableView does not select and does not repaint

Gunnar Sletta gunnar at trolltech.com
Wed Aug 27 12:15:36 CEST 2008


Curt Nowak wrote:
> Hi all,
>  
> I'm trying to implement a QTableView in which two consecutive rows are always marked as selected. For example: If the user clicks on row 1 then row 1 and row 2 should both be marked.
> I created a small example that shows where I'm stuck.
> There are two problems that I am having:
> [1] The blue marks on the table change only when it re-gains the window focus. (Click on a different window and then back on the application to see what I mean.)

Hi Curt,

The problem is that QTableView does a reset of the selection in the 
mouseReleaseEvent() based on the current mouse position in the view. You 
need to reimplement mouseReleaseEvent() to keep on selecting what you want.

> [2] I realize that in "on_selectionChanged" I always get a null-Index. The commented line in the same method aims to correct that but I can't figure out the correct settings.

I don't get what you mean here. The index is always valid when you have 
the mouse inside the view.

best regards,
Gunnar



More information about the Qt-jambi-interest mailing list