Index: src/UIElements/Qt4/Query/QtQuery.hpp
===================================================================
--- src/UIElements/Qt4/Query/QtQuery.hpp	(revision 7dfd07ff7c14ac5ea7a5146c49720f246584a67b)
+++ src/UIElements/Qt4/Query/QtQuery.hpp	(revision 7b8a8ede0fd727c6c8763a959f82bfa5784d5cda)
@@ -18,4 +18,5 @@
 #include "Qt4/QtDialog.hpp"
 #include "Parameters/Parameter.hpp"
+#include "QtQueryList.hpp"
 
 class QHBoxLayout;
@@ -326,5 +327,5 @@
 };
 
-class QtDialog::StringsQtQuery : public QWidget, public Dialog::StringsQuery {
+class QtDialog::StringsQtQuery : public QWidget, public Dialog::StringsQuery, public QtQueryList<std::string> {
   Q_OBJECT
 public:
@@ -333,13 +334,13 @@
   virtual bool handle();
 
-public slots:
-  void onUpdate();
-
-private:
-  QBoxLayout *parent;
-  QBoxLayout *thisLayout;
-  QLabel *titleLabel;
-  QLineEdit *inputBox;
-  Dialog *dialog;
+  virtual void onSubUpdate();
+
+public slots:
+  void onAddElement();
+  void onRemoveElement();
+  void onElementSelected();
+
+private:
+  StringQtQuery *subQuery;
 };
 
Index: src/UIElements/Qt4/Query/QtQueryList.cpp
===================================================================
--- src/UIElements/Qt4/Query/QtQueryList.cpp	(revision 7b8a8ede0fd727c6c8763a959f82bfa5784d5cda)
+++ src/UIElements/Qt4/Query/QtQueryList.cpp	(revision 7b8a8ede0fd727c6c8763a959f82bfa5784d5cda)
@@ -0,0 +1,85 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * QtQueryList.cpp
+ *
+ *  Created on: Jul 24, 2012
+ *      Author: ankele
+ */
+
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Qt/qboxlayout.h>
+#include <Qt/qpushbutton.h>
+#include <Qt/qlistwidget.h>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "UIElements/Qt4/Query/QtQueryList.hpp"
+
+
+QtQueryListUntyped::QtQueryListUntyped(QBoxLayout *parent, Dialog *_dialog) :
+  dialog(_dialog)
+{
+  thisVLayout = new QVBoxLayout();
+  thisHLayout = new QHBoxLayout();
+  buttonBox = new QVBoxLayout();
+  inputList = new QListWidget();
+  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  addButton = new QPushButton("Add");
+  addButton->setEnabled(false);
+  removeButton = new QPushButton("Remove");
+  removeButton->setEnabled(false);
+
+  buttonBox->addWidget(addButton);
+  buttonBox->addWidget(removeButton);
+  thisHLayout->addWidget(inputList);
+  thisHLayout->addLayout(buttonBox);
+  thisVLayout->addLayout(thisHLayout);
+  parent->addLayout(thisVLayout);
+}
+
+
+
+void QtQueryListUntyped::onUpdate() {
+  dialog->update();
+}
+
+
+void QtQueryListUntyped::elementSelected()
+{
+  removeButton->setEnabled(!inputList->selectedItems().empty());
+}
+
+void QtQueryListUntyped::addElementToListWidget(const std::string &str)
+{
+  inputList->addItem(QString(str.c_str()));
+}
+
+
+std::vector<int> QtQueryListUntyped::getSelectedRows()
+{
+  std::vector<int> rows;
+  QList<QListWidgetItem*> items = inputList->selectedItems();
+  for (QList<QListWidgetItem*>::iterator iter = items.begin(); !items.empty(); iter = items.begin()){
+    rows.push_back(inputList->row(*iter));
+    items.erase(iter);
+  }
+  return rows;
+}
+
+void QtQueryListUntyped::removeSelectedRows(const std::vector<int> &rows)
+{
+  for (int i = rows.size() - 1; i >= 0; i --)
+    inputList->takeItem(rows[i]);
+}
Index: src/UIElements/Qt4/Query/QtQueryList.hpp
===================================================================
--- src/UIElements/Qt4/Query/QtQueryList.hpp	(revision 7b8a8ede0fd727c6c8763a959f82bfa5784d5cda)
+++ src/UIElements/Qt4/Query/QtQueryList.hpp	(revision 7b8a8ede0fd727c6c8763a959f82bfa5784d5cda)
@@ -0,0 +1,124 @@
+/*
+ * QtQueryList.hpp
+ *
+ *  Created on: Jul 24, 2012
+ *      Author: ankele
+ */
+
+#ifndef QTQUERYLIST_HPP_
+#define QTQUERYLIST_HPP_
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "UIElements/Dialog.hpp"
+#include "Parameters/Parameter.hpp"
+
+class QListWidget;
+class QPushButton;
+class QVBoxLayout;
+class QHBoxLayout;
+class QBoxLayout;
+
+class QtQueryListUntyped {
+public:
+  QtQueryListUntyped(QBoxLayout *parent, Dialog *_dialog);
+  virtual ~QtQueryListUntyped(){}
+
+  virtual void onSubUpdate() = 0;
+
+  void onUpdate();
+  void elementSelected();
+  void addElementToListWidget(const std::string &str);
+  std::vector<int> getSelectedRows();
+  void removeSelectedRows(const std::vector<int> &rows);
+
+protected:
+  QListWidget *inputList;
+  QPushButton *addButton;
+  QPushButton *removeButton;
+  QVBoxLayout *thisVLayout;
+  QHBoxLayout *thisHLayout;
+  QVBoxLayout *buttonBox;
+  Dialog *dialog;
+};
+
+template<class T>
+class QtQueryList : public QtQueryListUntyped {
+public:
+  QtQueryList(QBoxLayout *parent, Dialog *_dialog, std::vector<T> &_temp) : QtQueryListUntyped(parent, _dialog), tempRef(_temp)
+  {
+    subParam = new Parameter<T>("sub-param");
+  }
+  virtual ~QtQueryList()
+  {
+    delete(subParam);
+  }
+
+  void addElement() {
+    // add item to both
+    addElementToListWidget(subParam->getAsString());
+    tempRef.push_back(subParam->get());
+    onUpdate();
+  }
+  void removeElements()
+  {
+    std::vector<int> rows = getSelectedRows();
+    removeSelectedRows(rows);
+    for (int i = rows.size() - 1; i >= 0; i --){
+      ASSERT(rows[i] < tempRef.size(), "QtQueryList<T>::removeElements() trying to remove invalid element.");
+      tempRef.erase(tempRef.begin() + rows[i]);
+    }
+    onUpdate();
+  }
+protected:
+  std::vector<T> &tempRef;
+  Parameter<T> *subParam;
+};
+
+
+
+class ListQuerySubDialog : public Dialog
+{
+public:
+  ListQuerySubDialog(QtQueryListUntyped *_parent) : parent(_parent), sub(NULL){}
+  virtual void update()
+  {
+    if (sub)
+      sub->handle();
+    parent->onSubUpdate();
+  }
+  void setSubQuery(Query *_sub){  sub = _sub; }
+
+  virtual void queryEmpty(const char*, std::string){}
+  virtual void queryBoolean(Parameter<bool> &, const char *, std::string = ""){}
+  virtual void queryInt(Parameter<int> &, const char *,std::string = ""){}
+  virtual void queryInts(Parameter<std::vector<int> > &, const char *,std::string = ""){}
+  virtual void queryUnsignedInt(Parameter<unsigned int> &, const char *,std::string = ""){}
+  virtual void queryUnsignedInts(Parameter<std::vector<unsigned int> > &, const char *,std::string = ""){}
+  virtual void queryDouble(Parameter<double> &, const char*,std::string = ""){}
+  virtual void queryDoubles(Parameter<std::vector<double> > &, const char*,std::string = ""){}
+  virtual void queryString(Parameter<std::string> &, const char*,std::string = ""){}
+  virtual void queryStrings(Parameter<std::vector<std::string> > &, const char*,std::string = ""){}
+  virtual void queryAtom(Parameter<const atom *> &, const char*,std::string = ""){}
+  virtual void queryAtoms(Parameter<std::vector<const atom *> > &, const char*,std::string = ""){}
+  virtual void queryMolecule(Parameter<const molecule *> &, const char*,std::string = ""){}
+  virtual void queryMolecules(Parameter<std::vector<const molecule *> > &, const char*,std::string = ""){}
+  virtual void queryVector(Parameter<Vector> &, const char*,std::string = ""){}
+  virtual void queryVectors(Parameter<std::vector<Vector> > &, const char*,std::string = ""){}
+  virtual void queryRealSpaceMatrix(Parameter<RealSpaceMatrix> &, const char*, std::string = ""){}
+  virtual void queryElement(Parameter<const element *> &, const char*,std::string = ""){}
+  virtual void queryElements(Parameter<std::vector<const element *> > &, const char*,std::string = ""){}
+  virtual void queryFile(Parameter<boost::filesystem::path> &, const char*,std::string = ""){}
+  virtual void queryFiles(Parameter<std::vector< boost::filesystem::path> > &, const char*,std::string = ""){}
+  virtual void queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &, const char*,std::string = ""){}
+private:
+  QtQueryListUntyped *parent;
+  Query *sub;
+};
+
+
+#endif /* QTQUERYLIST_HPP_ */
Index: src/UIElements/Qt4/Query/StringsQtQuery.cpp
===================================================================
--- src/UIElements/Qt4/Query/StringsQtQuery.cpp	(revision 7dfd07ff7c14ac5ea7a5146c49720f246584a67b)
+++ src/UIElements/Qt4/Query/StringsQtQuery.cpp	(revision 7b8a8ede0fd727c6c8763a959f82bfa5784d5cda)
@@ -18,13 +18,12 @@
 #endif
 
+#include <Qt/qpushbutton.h>
 #include <Qt/qboxlayout.h>
-#include <Qt/qlabel.h>
-#include <Qt/qlineedit.h>
 #include <Qt/qlistwidget.h>
-#include <Qt/qpushbutton.h>
 
 #include "CodePatterns/MemDebug.hpp"
 
 #include "UIElements/Qt4/Query/QtQuery.hpp"
+#include "UIElements/Qt4/Query/QtQueryList.hpp"
 #include "UIElements/Qt4/Pipe/QtQueryListPipe.hpp"
 
@@ -32,46 +31,35 @@
 QtDialog::StringsQtQuery::StringsQtQuery(Parameter<std::vector<std::string> > &_param, std::string _title,QBoxLayout *_parent,Dialog *_dialog) :
     Dialog::StringsQuery(_param, _title),
-    parent(_parent),
-    dialog(_dialog)
+    QtQueryList<std::string>(_parent, _dialog, temp)
 {
-  QHBoxLayout * thisHLayout = new QHBoxLayout();
-  QVBoxLayout * thisV1Layout = new QVBoxLayout();
-  QVBoxLayout * thisV2Layout = new QVBoxLayout();
+  ListQuerySubDialog *subDialog = new ListQuerySubDialog(this);
+  subQuery = new StringQtQuery(*subParam, _title, thisVLayout, subDialog);
+  subDialog->setSubQuery(subQuery);
 
-  QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
-  QLabel *inputLabel = new QLabel("Enter to add");
-  QListWidget* inputList = new QListWidget();
-  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
-  QLineEdit* inputBox = new QLineEdit();
-  inputLabel->setBuddy(inputBox);
-  titleLabel->setBuddy(inputList);
-  QPushButton* AddButton = new QPushButton("Add");
-  AddButton->setEnabled(false);
-  QPushButton* RemoveButton = new QPushButton("Remove");
-  RemoveButton->setEnabled(false);
-
-  thisV1Layout->addWidget(titleLabel);
-  thisV1Layout->addWidget(inputList);
-  thisV2Layout->addWidget(inputLabel);
-  thisV2Layout->addWidget(inputBox);
-  thisV2Layout->addWidget(AddButton);
-  thisV2Layout->addWidget(RemoveButton);
-  parent->addLayout(thisHLayout);
-  thisHLayout->addLayout(thisV1Layout);
-  thisHLayout->addLayout(thisV2Layout);
-
- /* pipe = new StringsQtQueryPipe(temp,_dialog,inputBox,inputList,AddButton,RemoveButton);
-  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(elementEntered(const QString&)));
-  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(elementSelected()));
-  connect(AddButton,SIGNAL(clicked()),pipe,SLOT(addElement()));
-  connect(RemoveButton,SIGNAL(clicked()),pipe,SLOT(removeElement()));*/
+  connect(inputList,SIGNAL(itemSelectionChanged()),this,SLOT(onElementSelected()));
+  connect(addButton,SIGNAL(clicked()),this,SLOT(onAddElement()));
+  connect(removeButton,SIGNAL(clicked()),this,SLOT(onRemoveElement()));
 }
 
 QtDialog::StringsQtQuery::~StringsQtQuery()
 {
+  delete(subQuery);
 }
 
-void QtDialog::StringsQtQuery::onUpdate() {
-  dialog->update();
+void QtDialog::StringsQtQuery::onSubUpdate()
+{
+  addButton->setEnabled(subParam->isSet());
+}
+
+void QtDialog::StringsQtQuery::onElementSelected() {
+  elementSelected();
+}
+
+void QtDialog::StringsQtQuery::onAddElement() {
+  addElement();
+}
+
+void QtDialog::StringsQtQuery::onRemoveElement() {
+  removeElements();
 }
 
@@ -79,18 +67,4 @@
 bool QtDialog::StringsQtQuery::handle()
 {
-/*  // dissect by ","
-  std::string::iterator olditer = temp.begin();
-  std::vector<std::string> temp_strings;
-  for(std::string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
-    if (*iter == ' ') {
-      temp_strings.push_back(std::string(iter, olditer));
-      olditer = iter;
-    }
-  }
-  if (olditer != temp.begin())  // insert last part also
-    temp_strings.push_back(std::string(olditer, temp.end()));
-  tmp.set(temp_strings);
-
-  return temp!="";*/
   if (param.isValid(temp)){
     param.set(temp);
