002
06.03.2007, 21:37 Uhr
Chiflada
|
aus dem konstruktor:
C++: |
lineEdits = new std::map<char*, QLineEdit*>(); for(int i=1; i<ncol; i++){ QString *label = new QString(result[i]); grid->addWidget(new QLabel(*label, this), i, 0); lineEdits->insert(std::map<char*, QLineEdit*>::value_type(result[i], new QLineEdit("Add data here", this, 0)));
std::map<char*, QLineEdit*>::iterator iter = lineEdits->find(result[i]); if(iter != lineEdits->end()) { grid->addWidget((*iter).second, i, 1); ++iter; } }
|
und aus der methode, die die map benutzt:
C++: |
std::map<char*, QLineEdit*>::iterator iter; std::string query ="insert into records values ("; for (int i=1; i<ncol; i++){ iter = lineEdits->find(result[i]); if(iter != lineEdits->end()) { lineEdit = (*iter).second; text = lineEdit->text(); query = query + "'" + text.latin1() + "'"; ++iter; } } query = query + ")"; DbControl::executeQuery(query); DbControl::freeTable();
|
|