(C++) SetReadOnlyTableWidget
February 24, 2017 · View on GitHub
(C++) SetReadOnlyTableWidget
SetReadOnlyTableWidget is a QTableWidget code snippet to render a QTableWidget read-only.
///SetReadOnlyTableWidget makes the QTableWidget read-only. ///From http://www.richelbilderbeek.nl/CppSetReadOnlyTableWidget.htm void SetReadOnlyTableWidget(QTableWidget * const t) { const int n_cols = t->columnCount(); const int n_rows = t->rowCount(); const Qt::ItemFlags f(Qt::ItemIsSelectable | Qt::ItemIsEnabled); for (int y=0; y!=n_rows; ++y) { for (int x=0; x!=n_cols; ++x) { QTableWidgetItem * i = new QTableWidgetItem; i->setFlags(f); t->setItem(x,y,i); } } }