New blog location
New blog location
class Dialog : public QDialog { Q_OBJECT public: Dialog(QWidget *parent = nullptr); ~Dialog(); private slots: void itemChanged(QStandardItem *item); private: Ui::Dialog *ui; QStandardItemModel model; void init(); };
void Dialog::init() { model.insertRows(0,4); model.insertColumns(0,4); for(int r = 0; r < model.rowCount(); r++) { for(int c = 0; c < model.columnCount(); c++) { QStandardItem* item = new QStandardItem(QString("row %0 col %1").arg(r).arg(c)); model.setItem(r,c,item); } } ui->tableView->setModel(&model); connect(&model, &QStandardItemModel::itemChanged,this,&Dialog::itemChanged); }
void Dialog::itemChanged(QStandardItem *item) { qInfo() << "Index: "<<item->index().row()<<item->index().column()<< " = "<<item->text(); }
Comments
Post a Comment