#include "stable.h" #include STable::STable() { } STable::~STable() { } void STable::keyPressEvent(QKeyEvent* event) { // If Ctrl-C typed if (event->key() == Qt::Key_C && (event->modifiers() & Qt::ControlModifier)) Copy(); } void STable::Copy() { QModelIndexList cells = selectedIndexes(); //qSort(cells); QString text; int currentRow = 0; foreach (const QModelIndex& cell, cells) { if (text.length() == 0) { } else if (cell.row() != currentRow) text += '\n'; else text += '\t'; currentRow = cell.row(); text += cell.data().toString(); } QApplication::clipboard()->setText(text); }