From ae4e340d3a0d6d7cae1ec4cf8ff46cba6a91cdf0 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 2 Jun 2020 10:50:41 +1000 Subject: [PATCH] Improve "Copy Cell Content" action code (cherry picked from commit 5ad9fc06157c33876b9d4496824ce4d014b2522a) --- src/gui/attributetable/qgsdualview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/attributetable/qgsdualview.cpp b/src/gui/attributetable/qgsdualview.cpp index 62df0f527732..c958597ec350 100644 --- a/src/gui/attributetable/qgsdualview.cpp +++ b/src/gui/attributetable/qgsdualview.cpp @@ -699,7 +699,11 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd QAction *copyContentAction = new QAction( tr( "Copy Cell Content" ), this ); copyContentAction->setData( QVariant::fromValue( atIndex ) ); menu->addAction( copyContentAction ); - connect( copyContentAction, &QAction::triggered, this, &QgsDualView::copyCellContent ); + connect( copyContentAction, &QAction::triggered, this, [atIndex, this] + { + QVariant var = mMasterModel->data( atIndex, Qt::DisplayRole ); + QApplication::clipboard()->setText( var.toString() ); + } ); QgsVectorLayer *vl = mFilterModel->layer(); QgsMapCanvas *canvas = mFilterModel->mapCanvas();