diff options
author | Samuel Gaist <samuel.gaist@idiap.ch> | 2020-08-20 09:32:12 +0200 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@idiap.ch> | 2020-08-29 23:26:58 +0200 |
commit | a646bcf2be23a65c6ee0a0efdeb6e787c80ac457 (patch) | |
tree | 34b4d287ec8c5436fd7936328bba8ca83227b6bd /src/widgets/itemviews | |
parent | add8262f72befc4c6a25403a21269030111054d1 (diff) |
QAbstractItemView: make clipboard copy less constrained
Currently when copying from an item view, only QString value types are
considered. This severely limits the usefulness of the feature as it
does not even allow to copy number nor dates that can be translated to
text.
This merge request changes that by checking if the content being copied
can be converted to a string rather that just being a string. This will
also allow for custom types to be handled.
Fixes: QTBUG-86166
Pick-to: 5.15
Change-Id: If57c986ef5831d59eeb59f9c4b900fa126ec31ea
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index a6b49c05b7..5d3fa4a088 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -2340,7 +2340,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) QVariant variant; if (d->model) variant = d->model->data(currentIndex(), Qt::DisplayRole); - if (variant.userType() == QMetaType::QString) + if (variant.canConvert<QString>()) QGuiApplication::clipboard()->setText(variant.toString()); event->accept(); } |