[Qt-interest] how to prevent selecting multiple columns in a QTableView

Andy Hirsh andhirsh at gmail.com
Thu Oct 28 17:24:45 CEST 2010


Hello Samuel

  mmm... maybe I'm doing something wrong, but I was not able to set this
behaviour using the two functions you talk about; what I need is to allow
multiple item selection, but only if they are on the same column.

note that setting:

   tableView->setSelectionBehavior(QAbstractItemView::SelectColumns);

will select always the entire column, while I want to be able to select only
part of it...

  thanks a lot for your help

          Andy

On Thu, Oct 28, 2010 at 5:11 PM, Samuel Gaist <samuel.gaist at edeltech.ch>wrote:

>
> On 28 oct. 10, at 17:06, Andy Hirsh wrote:
>
> > Dear listener,
> >
> >  is there a way to prevent the user from selecting multiple columns
> > in a table ?
> >
> >  I've try intercepting the currentColumnChanged() signal of the
> > selection model this way:
> >
> > -------------
> >  ...
> >  connect(selectionmodel, SIGNAL(currentColumnChanged(
> > const
> > QModelIndex, const QModelIndex)),
> >                               this,
> > SLOT(currentSelectionColumnChangedSLO(const QModelIndex, const
> > QModelIndex)));
> >  ...
> >
> >   void NPenMapModel::currentSelectionColumnChangedSLO(const
> > QModelIndex &current, const QModelIndex &previous)
> >   {
> >      selectionmodel->select(previous,
> > QItemSelectionModel::Current|QItemSelectionModel::Deselect|
> > QItemSelectionModel::Columns);
> >   }
> >
> > ------------
> >
> >  but with no success
> >
> >  any idea will be appreciated :D
> >
> >    thanks a lot,
> >
> >             Andy
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
> Hello,
>
> You might be interested in looking at:
> http://doc.trolltech.com/4.7/qabstractitemview.html#selectionBehavior-prop
> and
> http://doc.trolltech.com/4.7/qabstractitemview.html#selectionMode-prop
>
> Hope this helps
> Samuel
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101028/0169ecb8/attachment.html 


More information about the Qt-interest-old mailing list