#ifndef FILTER_GUI_C #define FILTER_GUI_C #include #include #include #include #include #include #include class FilterGui { private: QTableWidget* widget; int size; int* data; void recreateDataStorage() { if(data != NULL) { delete data; data = NULL; } int fields = this->size * this->size; data = (int*) malloc(sizeof(int) * fields); for(int i=0; iwidget->setRowCount(this->size); this->widget->setColumnCount(this->size); for(int i=0; isize; i++) { for(int j=0; jsize; j++) { this->widget->setItem(i, j, new QTableWidgetItem("0")); } } }; void fetchData() { for(int i=0; isize; i++) { for(int j=0; jsize; j++) { QString temp = this->widget->item(i, j)->text(); this->data[i*this->size + j] = temp.toInt(); } } }; public: FilterGui(int filter_size = 3) { this->data = NULL; this->widget = new QTableWidget(); this->setSize(filter_size); }; ~FilterGui() { if(this->widget != NULL) { delete this->widget; this->widget = NULL; } if(this->data != NULL) { delete this->data; this->data = NULL; } }; QTableWidget* getWidget() { return this->widget; }; void setSize(int size) { this->size = size; this->updateGui(); }; int getSize() { return this->size; }; int* getData() { this->recreateDataStorage(); this->fetchData(); return this->data; } }; #endif