From 88bd90f51ad9196714ae728ccb72e786f1de9675 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 25 Oct 2017 12:19:26 -0700 Subject: [PATCH] try basic code from SO --- mainwindow.cpp | 8 ++++++++ mainwindow.h | 1 + 2 files changed, 9 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index fa970ee..c017a60 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -54,6 +54,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->canFramesView->setColumnWidth(6, 225); QHeaderView *HorzHdr = ui->canFramesView->horizontalHeader(); HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview + connect(HorzHdr, SIGNAL(sectionClicked(int)), this, SLOT(on_sectionClicked(int))); graphingWindow = NULL; frameInfoWindow = NULL; @@ -234,6 +235,13 @@ void MainWindow::closeEvent(QCloseEvent *event) exitApp(); } +void MainWindow::on_sectionClicked ( int logicalIndex ) +{ + QHeaderView *HorzHdr = ui->canFramesView->horizontalHeader(); + HorzHdr->setSortIndicator(logicalIndex, Qt::AscendingOrder); + ui->canFramesView->sortByColumn(logicalIndex); +} + void MainWindow::updateSettings() { readUpdateableSettings(); diff --git a/mainwindow.h b/mainwindow.h index 9e70597..bade9bf 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -102,6 +102,7 @@ public slots: void readUpdateableSettings(); void gotCenterTimeID(int32_t ID, double timestamp); void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1); + void on_sectionClicked ( int logicalIndex ); signals: void sendCANFrame(const CANFrame *, int);