[PyQt] selectionChanged or currentChanged in QTreeView

Andreas Pakulat apaku at gmx.de
Thu Oct 7 07:41:57 BST 2010


On 06.10.10 22:40:28, danny wrote:
> > Are you sure, that the activated signal doesn't fit your needs?
> 
> Unfortunately, yes. I forgot to mention, that I have the activated signal
> connected to a slot that shows when it fires. I also have both selectionChanged
> and currentChanged overridden to show when they execute.
> 
> My app constructs a tree by drag and drop. When I drop a node, I immediately
> make that node current and edit it's text. The execution order seems to
> selectionChanged, then currentChanged. The activated signal never fires  at all. 

The reason is that activated is sent out depending on the platform
you're running on. For example on win32 its only sent when
double-clicking the item, on macosx (IIRC) its sent out on single-click.
Same thing on KDE4, if KDE4 is configured for single-click.

> FWIW, in opposition to what you say, selectionChanged and currentChanged always
> seem to fire together. I have not yet seen a case where only one fires.

They don't if you have a contigous or extended selection set and use the
mouse to select multiple items with Ctrl+Click or Shift+Click. In such
cases selectionChanged is emitted, but not currentChanged.
currentChanged is only emitted when you click (without keyboard
modifier) onto an item or if you use the keyboard to navigate in the
view.

So you'll have to decide between them based on what selection is
possible in the view. But you certainly don't need to override any
function to do what you want, just connect the right signal.

Andreas

-- 
You will be advanced socially, without any special effort on your part.


More information about the PyQt mailing list