How exactly does the whole high lighting in a QTableView work? I actually want it to be more of a multiple column list view, aka not editable with the exception for the first column which is ItemIsUserCheckable. I have the model configured correctly so that only the first column is selectable. It is similar to the code I posted in this thread:
http://www.qtcentre.org/threads/3220...eView?p=149856
But I have tweaked the settings a bit. I am using QT Designer, so here is what is in the generated code:
customerTableView
->setObjectName
(QString::fromUtf8("customerTableView"));
customerTableView
->setProperty
("showDropIndicator",
QVariant(true));
customerTableView->setAlternatingRowColors(true);
customerTableView->setSortingEnabled(true);
customerTableView->setCornerButtonEnabled(false);
customerTableView
->horizontalHeader
()->setProperty
("showSortIndicator",
QVariant(true));
customerTableView->verticalHeader()->setHighlightSections(false);
customerTableView->setObjectName(QString::fromUtf8("customerTableView"));
customerTableView->setEditTriggers(QAbstractItemView::SelectedClicked);
customerTableView->setProperty("showDropIndicator", QVariant(true));
customerTableView->setAlternatingRowColors(true);
customerTableView->setSelectionMode(QAbstractItemView::SingleSelection);
customerTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
customerTableView->setSortingEnabled(true);
customerTableView->setCornerButtonEnabled(false);
customerTableView->horizontalHeader()->setProperty("showSortIndicator", QVariant(true));
customerTableView->verticalHeader()->setHighlightSections(false);
To copy to clipboard, switch view to plain text mode
The feature I am working on now is allowing the user to select a row which will enable two buttons (delete/edit). What is happening is when I select a row, then click on one of the buttons, the row that was highlighted isn't highlighted anymore. Also, I don't know how to get a signal or event on when the row is no longer highlighted, so the buttons can be disabled.
Question:
- How to keep the row selected when clicking on a widget outside the tree?
- How to detect when no row is highlighted, so button state can change correctly?
Sam
Bookmarks