Index: src/UIElements/Dialog.cpp
===================================================================
--- src/UIElements/Dialog.cpp	(revision fa27ed6e67dc2377992b473bb19c8211f6e48f82)
+++ src/UIElements/Dialog.cpp	(revision f8879dd41341e9b0285c43f7d9eec41d28414400)
@@ -29,4 +29,14 @@
 
 bool Dialog::display(){
+  if(checkAll()){
+    setAll();
+    return true;
+  }
+  else{
+    return false;
+  }
+}
+
+bool Dialog::checkAll(){
   list<Query*>::iterator iter;
   bool retval = true;
@@ -37,11 +47,12 @@
       break;
   }
-  if (retval){
-    // if all queries succeeded we can set the targets to appropriate values
-    for(iter=queries.begin(); iter!=queries.end(); iter++) {
-      (*iter)->setResult();
-    }
+  return retval;
+}
+
+void Dialog::setAll(){
+  list<Query*>::iterator iter;
+  for(iter=queries.begin(); iter!=queries.end(); iter++) {
+    (*iter)->setResult();
   }
-  return retval;
 }
 
@@ -74,5 +85,7 @@
 
 Dialog::StringQuery::StringQuery(string title,string *_target) :
-    Query(title), target(_target)
+    Query(title),
+    target(_target),
+    tmp("")
 {}
 
Index: src/UIElements/Dialog.hpp
===================================================================
--- src/UIElements/Dialog.hpp	(revision fa27ed6e67dc2377992b473bb19c8211f6e48f82)
+++ src/UIElements/Dialog.hpp	(revision f8879dd41341e9b0285c43f7d9eec41d28414400)
@@ -26,4 +26,7 @@
 
   virtual bool display();
+
+  virtual bool checkAll();
+  virtual void setAll();
 
 protected:
Index: src/UIElements/QT4/QTDialog.cpp
===================================================================
--- src/UIElements/QT4/QTDialog.cpp	(revision f8879dd41341e9b0285c43f7d9eec41d28414400)
+++ src/UIElements/QT4/QTDialog.cpp	(revision f8879dd41341e9b0285c43f7d9eec41d28414400)
@@ -0,0 +1,224 @@
+/*
+ * QTDialog.cpp
+ *
+ *  Created on: Jan 18, 2010
+ *      Author: crueger
+ */
+
+#include "UIElements/QT4/QTDialog.hpp"
+
+#include <string>
+#include <sstream>
+
+#include <Qt/qboxlayout.h>
+#include <Qt/qlabel.h>
+#include <Qt/qspinbox.h>
+#include <Qt/qlineedit.h>
+#include <Qt/qdialogbuttonbox.h>
+#include <Qt/qpushbutton.h>
+#include <Qt/qcombobox.h>
+
+#include "atom.hpp"
+#include "molecule.hpp"
+
+
+using namespace std;
+
+QTDialog::QTDialog() :
+    QDialog(0)
+{
+  // creating and filling of the Dialog window
+  mainLayout = new QVBoxLayout();
+  inputLayout = new QVBoxLayout();
+  buttonLayout = new QVBoxLayout();
+  setLayout(mainLayout);
+  mainLayout->addLayout(inputLayout);
+  mainLayout->addLayout(buttonLayout);
+  buttons = new QDialogButtonBox(QDialogButtonBox::Ok| QDialogButtonBox::Cancel);
+  buttonLayout->addWidget(buttons);
+
+  // Disable the ok button until something was entered
+  buttons->button(QDialogButtonBox::Ok)->setEnabled(false);
+
+  // connect the buttons to their appropriate slots
+  connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
+  connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+QTDialog::~QTDialog()
+{
+}
+
+bool QTDialog::display(){
+  // Button state might have changed by some update that
+  // was done during query construction. To make sure
+  // the state is correct, we just call update one more time.
+  update();
+  if(exec()) {
+    setAll();
+    return true;
+  }
+  else {
+    return false;
+  }
+}
+
+void QTDialog::update(){
+  buttons->button(QDialogButtonBox::Ok)->setEnabled(checkAll());
+}
+
+/************************** Query Infrastructure ************************/
+
+void QTDialog::queryInt(const char *title, int *target)
+{
+  registerQuery(new IntQTQuery(title,target,inputLayout,this));
+}
+
+void QTDialog::queryString(const char* title, std::string *target)
+{
+  registerQuery(new StringQTQuery(title,target,inputLayout,this));
+}
+
+void QTDialog::queryMolecule(const char *title,molecule **target,MoleculeListClass *molecules)
+{
+  registerQuery(new MoleculeQTQuery(title,target,molecules,inputLayout,this));
+}
+
+QTDialog::IntQTQuery::IntQTQuery(string _title,int *_target,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::IntQuery(_title,_target),
+    parent(_parent)
+{
+  thisLayout = new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  inputBox = new QSpinBox();
+  inputBox->setValue(0);
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new IntQTQueryPipe(&tmp,_dialog);
+  pipe->update(inputBox->value());
+  connect(inputBox,SIGNAL(valueChanged(int)),pipe,SLOT(update(int)));
+}
+
+QTDialog::IntQTQuery::~IntQTQuery()
+{
+  delete pipe;
+}
+
+// Handling is easy since the GUI makes it impossible to enter invalid values
+bool QTDialog::IntQTQuery::handle()
+{
+  return true;
+}
+
+
+QTDialog::StringQTQuery::StringQTQuery(string _title,string *_target,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::StringQuery(_title,_target),
+    parent(_parent)
+{
+  thisLayout = new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  inputBox = new QLineEdit();
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new StringQTQueryPipe(&tmp,_dialog);
+  pipe->update(inputBox->text());
+  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&)));
+}
+
+QTDialog::StringQTQuery::~StringQTQuery()
+{
+  delete pipe;
+}
+
+// All values besides the empty string are valid
+bool QTDialog::StringQTQuery::handle()
+{
+  return tmp!="";
+}
+
+QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target, MoleculeListClass *_molecules, QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::MoleculeQuery(_title,_target,_molecules),
+    parent(_parent)
+{
+  MoleculeList::iterator iter;
+  thisLayout = new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  inputBox = new QComboBox();
+  // add all molecules to the combo box
+  for(iter  = molecules->ListOfMolecules.begin();
+      iter != molecules->ListOfMolecules.end();
+      iter++) {
+    stringstream sstr;
+    sstr << (*iter)->IndexNr << "\t" << (*iter)->name;
+    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
+  }
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox,_molecules);
+  pipe->update(inputBox->currentIndex());
+  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
+}
+
+QTDialog::MoleculeQTQuery::~MoleculeQTQuery()
+{
+  delete pipe;
+}
+
+// Handling is easy, since the GUI makes it impossible to select invalid values
+bool QTDialog::MoleculeQTQuery::handle()
+{
+  return true;
+}
+
+
+/*************************** Plumbing *******************************/
+
+StringQTQueryPipe::StringQTQueryPipe(string *_content, QTDialog *_dialog) :
+  content(_content),
+  dialog(_dialog)
+{}
+
+StringQTQueryPipe::~StringQTQueryPipe()
+{}
+
+void StringQTQueryPipe::update(const QString& newText) {
+  content->assign(newText.toStdString());
+  dialog->update();
+}
+
+IntQTQueryPipe::IntQTQueryPipe(int *_content, QTDialog *_dialog) :
+  content(_content),
+  dialog(_dialog)
+{}
+
+IntQTQueryPipe::~IntQTQueryPipe()
+{}
+
+void IntQTQueryPipe::update(int newInt) {
+  (*content) = newInt;
+  dialog->update();
+}
+
+MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox, MoleculeListClass *_molecules) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox),
+  molecules(_molecules)
+{}
+
+MoleculeQTQueryPipe::~MoleculeQTQueryPipe()
+{}
+
+void MoleculeQTQueryPipe::update(int newIndex) {
+  QVariant data = theBox->itemData(newIndex);
+  int idx = data.toInt();
+  (*content) = molecules->ReturnIndex(idx);
+  dialog->update();
+}
+
Index: src/UIElements/QT4/QTDialog.hpp
===================================================================
--- src/UIElements/QT4/QTDialog.hpp	(revision f8879dd41341e9b0285c43f7d9eec41d28414400)
+++ src/UIElements/QT4/QTDialog.hpp	(revision f8879dd41341e9b0285c43f7d9eec41d28414400)
@@ -0,0 +1,143 @@
+/*
+ * QTDialog.hpp
+ *
+ *  Created on: Jan 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef QTDIALOG_HPP_
+#define QTDIALOG_HPP_
+
+#include "UIElements/Dialog.hpp"
+#include <Qt/qdialog.h>
+
+class QBoxLayout;
+class QLabel;
+class QSpinBox;
+class QLineEdit;
+class QComboBox;
+class QDialogButtonBox;
+
+
+// Forward declarations for plumbing
+class StringQTQueryPipe;
+class IntQTQueryPipe;
+class MoleculeQTQueryPipe;
+
+class QTDialog : public QDialog, public Dialog
+{
+  Q_OBJECT
+public:
+  QTDialog();
+  virtual ~QTDialog();
+
+  virtual void queryInt(const char *, int *);
+  virtual void queryString(const char*, std::string *);
+  virtual void queryMolecule(const char*,molecule**,MoleculeListClass*);
+
+  virtual bool display();
+
+  virtual void update();
+
+protected:
+  class IntQTQuery : public Dialog::IntQuery {
+    public:
+      IntQTQuery(std::string _title, int *_target,QBoxLayout *_parent,QTDialog *_dialog);
+      ~IntQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QSpinBox *inputBox;
+
+      IntQTQueryPipe *pipe;
+    };
+
+    class StringQTQuery : public Dialog::StringQuery {
+    public:
+      StringQTQuery(std::string _title, std::string *_target, QBoxLayout *_parent,QTDialog *_dialog);
+      ~StringQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QLineEdit *inputBox;
+
+      StringQTQueryPipe *pipe;
+    };
+
+    class MoleculeQTQuery : public Dialog::MoleculeQuery {
+    public:
+      MoleculeQTQuery(std::string _title, molecule **_target, MoleculeListClass *_molecules, QBoxLayout *_parent,QTDialog *_dialog);
+      ~MoleculeQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QComboBox *inputBox;
+
+      MoleculeQTQueryPipe *pipe;
+    };
+
+private:
+  QBoxLayout *mainLayout;
+  QBoxLayout *inputLayout;
+  QBoxLayout *buttonLayout;
+  QDialogButtonBox *buttons;
+};
+
+// All kinds of plumbing for Queries
+// Plumbing needs to be outside of the class where it is needed,
+// since MOC doesn't like nested classes
+
+class StringQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  StringQTQueryPipe(std::string *_content, QTDialog *_dialog);
+  ~StringQTQueryPipe();
+
+public slots:
+  void update(const QString&);
+
+private:
+  std::string *content;
+  QTDialog *dialog;
+
+};
+
+class IntQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  IntQTQueryPipe(int *_content, QTDialog *_dialog);
+  ~IntQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  int *content;
+  QTDialog *dialog;
+
+};
+
+
+class MoleculeQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox, MoleculeListClass *_molecules);
+  ~MoleculeQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  molecule **content;
+  MoleculeListClass *molecules;
+  QTDialog *dialog;
+  QComboBox *theBox;
+
+};
+#endif /* QTDIALOG_HPP_ */
Index: src/UIElements/QT4/QTUIFactory.cpp
===================================================================
--- src/UIElements/QT4/QTUIFactory.cpp	(revision fa27ed6e67dc2377992b473bb19c8211f6e48f82)
+++ src/UIElements/QT4/QTUIFactory.cpp	(revision f8879dd41341e9b0285c43f7d9eec41d28414400)
@@ -15,4 +15,5 @@
 #include "UIElements/QT4/QTUIFactory.hpp"
 #include "UIElements/QT4/QTMainWindow.hpp"
+#include "UIElements/QT4/QTDialog.hpp"
 #include "defs.hpp"
 
@@ -29,6 +30,5 @@
 
 Dialog* QTUIFactory::makeDialog() {
-  assert(0 && "Not implemented yet");
-  return 0;
+  return new QTDialog();
 }
 
