[Interest] What did I do?
Rainer Wiesenfarth
Rainer_Wiesenfarth at trimble.com
Wed Sep 5 07:34:01 CEST 2012
Am 05.09.2012 07:11, schrieb K. Frank:
> On Tue, Sep 4, 2012 at 6:37 PM, Bill Crocker <...> wrote:
> > In my app, when I click in a section of the horizontal header a table view,
> > all items in the corresponding column are selected.
>
> I see the same behavior. (To confirm: using QTableView.)
> [...]
> I assume that it's the default behavior, because I don't do anything
> explicit to enable it.
>
> > How do I turn off this behavior?
If - and only if ;-) - setting
view->setSelectionBehavior (QAbstractItemView::SelectItems);
does not help, this _might_ be an option:
1) Create a custom selection model class where you overload the two
select() methods:
class MySelectionModel : public QItemSelectionModel
{
public:
MySelectionModel (QAbstractItemModel *model)
: QItemSelectionModel (model)
{ }
MySelectionModel (QAbstractItemModel *model, QObject *parent)
: QItemSelectionModel (model, parent)
{ }
virtual void select (const QModelIndex &index
, QItemSelectionModel::SelectionFlags command)
{
command &= ~QItemSelectionModel::Columns;
QItemSelectionModel::select (index, command);
}
virtual void select (const QItemSelection &selection
, QItemSelectionModel::SelectionFlags command)
{
command &= ~QItemSelectionModel::Columns;
QItemSelectionModel::select (selection, command);
}
};
2) Assign an instance of this selection model to your view:
view->setSelectionModel (new MySelectionModel (view->model ()));
Maybe you have to play a little with your selection model. You might
also want to play with different settings of SelectionBehavior and/or
SelectionMode.
Best Regards / Mit freundlichen Grüßen
Rainer Wiesenfarth
--
Tel.: +49 (0)711 22 88-10 * Fax: +49 (0)711 22 88-111
Web: http://www.trimble.com/geospatial/ * http://www.inpho.de/
Trimble Germany GmbH * Branch office Stuttgart
Rotebühlstraße 81 * 70178 Stuttgart * Germany
Commercial register: HRB 83893, Darmstadt
Managing Directors: Dr. Frank Heimberg, Hans-Jürgen Gebauer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4502 bytes
Desc: S/MIME Kryptografische Unterschrift
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120905/f9bf8baa/attachment.bin>
More information about the Interest
mailing list