How to detect the modifier key on mouse click
On Qt 4, try QApplication::keyboardModifiers(). The Qt 5 and Qt 6 equivalent is QGuiApplication::keyboardModifiers().
On Qt 4, try QApplication::keyboardModifiers(). The Qt 5 and Qt 6 equivalent is QGuiApplication::keyboardModifiers().
There are two methods: void QTableWidget::setCellWidget(int row, int column, QWidget* widget) and void QListWidget::setItemWidget(QListWidgetItem* item, QWidget* widget) They allow to insert any widget and other controls that inherit QWidget. Checkbox/radio button/combobox do inherit from QWidget.
cmannett85’s recommendation is a good one. Read the docs about a dozen times. Then, if performance and memory issues are your primary concern and you think you can out-perform the QTableWidget implementation, then a QTableView interface on top of a QAbstractTableModel or QStandardItemModel is what you’re looking for. Since you’re new to Qt’s model-view architecture, … Read more
Just set the row count to 0 with: mTestTable->setRowCount(0); it will delete the QTableWidgetItems automatically, by calling removeRows as you can see in QTableWidget internal model code: void QTableModel::setRowCount(int rows) { int rc = verticalHeaderItems.count(); if (rows < 0 || rc == rows) return; if (rc < rows) insertRows(qMax(rc, 0), rows – rc); else removeRows(qMax(rows, … Read more
Insert into the QTableWidget following kind of items: QTableWidgetItem *item = new QTableWidgetItem(); item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); Works fine! EDIT: QTableWidgetItem *item = new QTableWidgetItem(); item->setFlags(item->flags() ^ Qt::ItemIsEditable); This is a better solution. Thanks to @priomsrb.