48 tableWidget->setColumnCount(2);
50 QStringList horizontalHeaders;
51 horizontalHeaders.append(
"Name");
52 horizontalHeaders.append(
"Value");
53 tableWidget->setHorizontalHeaderLabels(horizontalHeaders);
55 tableWidget->verticalHeader()->hide();
60 tableWidget->setRowCount(properties->size());
65 QTableWidgetItem* textItem =
new QTableWidgetItem;
67 textItem->setFlags(textItem->flags() & ~Qt::ItemIsEditable);
68 tableWidget->setItem(r, 0, textItem);
73 QTableWidgetItem* checkItem =
new QTableWidgetItem;
74 checkItem->setText(
"enabled");
75 checkItem->setFlags(checkItem->flags() | Qt::ItemIsUserCheckable);
77 checkItem->setCheckState(Qt::Checked);
79 checkItem->setCheckState(Qt::Unchecked);
80 tableWidget->setItem(r, 1, checkItem);
82 QLineEdit* editor =
new QLineEdit(tableWidget);
83 editor->setText(QString::fromStdString(it->second->toString()));
85 editor->setValidator(
new QIntValidator(editor));
88 editor->setValidator(
new QDoubleValidator(editor));
91 editor->setValidator(
new QDoubleValidator(editor));
93 tableWidget->setCellWidget(r, 1, editor);
97 tableWidget->resizeColumnToContents(0);
102 assert(tableWidget->rowCount() == (int)
_propNames.size());
104 for (
int r = 0; r < tableWidget->rowCount(); ++r) {
112 QTableWidgetItem* checkItem = tableWidget->item(r, 1);
113 prop->
setValue(checkItem->checkState() == Qt::Checked);
115 QLineEdit* editor =
dynamic_cast<QLineEdit*
>(tableWidget->cellWidget(r, 1));
116 bool status = baseProp->
fromString(editor->text().toStdString());
118 cerr <<
"Warning: unable to set property " << baseProp->
name() << endl;
BaseClass::iterator PropertyMapIterator
virtual bool fromString(const std::string &s)=0
void setValue(const T &v)
a collection of properties mapping from name to the property itself
const std::string & name()