[Interest] Catching selection in QTreeView
Waitman Gobble
uzimac at da3m0n8t3r.com
Tue Jun 19 09:45:39 CEST 2012
Waitman Gobble <uzimac at da3m0n8t3r.com> wrote ..
> Andreas Pakulat <apaku at gmx.de> wrote ..
> > Hi,
> >
> > On Tue, Jun 19, 2012 at 8:32 AM, Waitman Gobble <uzimac at da3m0n8t3r.com>wrote:
> >
> > >
> > > Hi,
> > >
> > > I am having an issue with the QTreeView and Key Bindings. It seems when
> > > the selection changes from a keyboard event, it does not fire the function
> > > bound to the signal. The mouse button causes the function to run as
> > > desired. Perhaps I'm missing a setting in the documentation?
> > >
> >
> > Are you expecting your "changeCurrent" slot to be called when navigating
> > the tree with keyboard? If so, thats where your error is. You connected the
> > pressed-signal of the treeview to that slot and the documentation clearly
> > states that this signal is emitted when a mouse button is pressed. If you
> > want to catch selection changes of your tree, you should look at the
> > signals of the QItemSelectionModel class. You can obtain the
> > selection-model from the treeview using the selectionModel member functions
> >
> > Andreas
>
>
> Thanks Andreas,
>
> I tried the signals that looked like they would fire the function, I suppose I
> left the least likely candidate in the exanple.
> I will take a look at the selectionModel member functions.
>
> I appreciate your help.
>
> Waitman
>
> --
> Waitman Gobble
> San Jose California USA
This appears to be working for me.
connect( tree->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT( changeCurrent(QItemSelection,QItemSelection)), Qt::DirectConnection ) ;
Thanks,
--
Waitman Gobble
San Jose California USA
More information about the Interest
mailing list