public HttpServerExample(QWidget parent) {
    server = new HttpServer(this);
    if (!server.start()) {
      QMessageBox.critical(
          this, tr("HTTP Server"), tr("Unable to start the server: ") + server.errorString());
      close();
    }

    QPushButton publishButton = new QPushButton(this);
    publishButton.setText("Publish");
    editor = new QTextEdit(this);

    editor.setPlainText(
        "<h1>Server is up and running!</h1>"
            + "You should be able to view it in a normal web browser."
            + " Try this address: http://localhost:"
            + server.serverPort());

    QGridLayout layout = new QGridLayout(this);
    setLayout(layout);
    layout.addWidget(publishButton);
    layout.addWidget(editor);

    publishButton.clicked.connect(this, "publish()");

    setWindowTitle(tr("Simple HTTP Server"));
    setWindowIcon(new QIcon("classpath:com/trolltech/images/qt-logo.png"));
  }
 protected void publish() {
   server.publish(editor.toPlainText());
 }