Qt-interest Archive, January 2007
Selecting multiple rows in QTableView
Message 1 in thread
Hi,
How do I select multiple rows in a QTableView (Qt 4.2.2) without the
shift or control key? I have a graphical view of the data in which
users can select items with the mouse, but I can't figure out how to
add those items to the selected items in the QTableView. As far as I
can tell, QTableView::selectRow() selects 1 row, unless the control or
shift key is pressed (which I don't want). I've also tried calling
QTableView::selectionModel()->select() with no luck. Also, once
multiple items are selected, how do I unselect rows? There is an old
message about it, but I'm hoping there is an easier way now.
Thanks in advance,
Mike
--
[ signature omitted ]
Message 2 in thread
On 24.01.07 18:55:24, Michael Schatz wrote:
> How do I select multiple rows in a QTableView (Qt 4.2.2) without the
> shift or control key? I have a graphical view of the data in which
> users can select items with the mouse, but I can't figure out how to
> add those items to the selected items in the QTableView. As far as I
> can tell, QTableView::selectRow() selects 1 row, unless the control or
> shift key is pressed (which I don't want). I've also tried calling
> QTableView::selectionModel()->select() with no luck. Also, once
> multiple items are selected, how do I unselect rows? There is an old
> message about it, but I'm hoping there is an easier way now.
Try to set the selection mode of the view to MultiSelection. That should
do what you want.
Andreas
--
[ signature omitted ]
Message 3 in thread
That worked great.
Thanks,
Mike
On 1/24/07, Andreas Pakulat <apaku@xxxxxx> wrote:
> On 24.01.07 18:55:24, Michael Schatz wrote:
> > How do I select multiple rows in a QTableView (Qt 4.2.2) without the
> > shift or control key? I have a graphical view of the data in which
> > users can select items with the mouse, but I can't figure out how to
> > add those items to the selected items in the QTableView. As far as I
> > can tell, QTableView::selectRow() selects 1 row, unless the control or
> > shift key is pressed (which I don't want). I've also tried calling
> > QTableView::selectionModel()->select() with no luck. Also, once
> > multiple items are selected, how do I unselect rows? There is an old
> > message about it, but I'm hoping there is an easier way now.
>
> Try to set the selection mode of the view to MultiSelection. That should
> do what you want.
>
> Andreas
>
> --
> Your love life will be happy and harmonious.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]