Highlight table column
-
Hello , i have a QStandardItemModel table and i'd like to highlight one of the column after the occurrence of an event.
To be more clear i have this situation at start
in this other picture is shown what i'm trying to reach. this is what is happening when i'm clicking the header of the table definited by HorizontalHeaderLabel "4". So basically I'm trying to figure out how to simulate the click on the header defined by headerlabel "4"
And this is the way i get the column values
void measure::on_tableViewTop_clicked(const QModelIndex &index) { ui->tableViewTop->setCurrentIndex (index); int r = index.row(); int c = index.column (); qDebug() << "Row: " << r; qDebug() << "Column: " << c; qDebug() << "X: " << ui->tableViewTop->model()->data(ui->tableViewTop->model()->index(0,c)).toString(); qDebug() << "Y: " << ui->tableViewTop->model()->data(ui->tableViewTop->model()->index(1,c)).toString(); qDebug() << "Z: " << ui->tableViewTop->model()->data(ui->tableViewTop->model()->index(2,c)).toString(); }
Hope you can help ;) And forive me for my not so clear english :P
-
Noone knows how to do it? :(
-
Hi! Please refrain from thread bumping.
Selecting items is done in the view, not in the model.
void QTableView::selectColumn(int column) [slot]
, see: QTableView Class. -
What's your view
selectionMode
andselectionBehaviour
? do you reimplement a selectEvent? -
@Wieland said in Highlight table column:
Hi! Please refrain from thread bumping.
Selecting items is done in the view, not in the model.
void QTableView::selectColumn(int column) [slot]
, see: QTableView Class.Sorry didn't want to spam or do thread bumbing. It's the first time i'm having this behaviour after many posts
@VRonin said in Highlight table column:
What's your view
selectionMode
andselectionBehaviour
? do you reimplement a selectEvent?The selection mode is "ExtendedSelection" while the selectionBehaviour is "SelectItems"
Changing it to selectColumns seems to do what i wanted to do...Thanks for pointing me to the right direction ;)