MyMainWindow::createUI()
    {
        label = new QLabel("foo");
        button = new QPushButton("Browse");
        connect(button, SIGNAL(clicked()), SLOT(browse()));
        layout = new QHorizontalLayout();
        layout->addWidget(label);
        layout->addWidget(button);
        setLayout(layout);
    }

    void MyMainWindow::browse()
    {
        QString directory = QFileDialog::getExistingDirectory(this,
                                tr("Find Files"), QDir::currentPath());

        if (!directory.isEmpty()) {
            if (directoryComboBox->findText(directory) == -1)
                directoryComboBox->addItem(directory);
            directoryComboBox->setCurrentIndex(directoryComboBox->findText(directory));
        }
    }

MyMainWindow::createUI()
{
    label = new QLabel("foo");
    button = new QPushButton("Browse");
    connect(button, SIGNAL(clicked()), SLOT(browse()));
    layout = new QHorizontalLayout();
    layout->addWidget(label);
    layout->addWidget(button);
    setLayout(layout);
}

void MyMainWindow::browse()
{
    QString directory = QFileDialog::getExistingDirectory(this,
                            tr("Find Files"), QDir::currentPath());

    if (!directory.isEmpty()) {
        if (directoryComboBox->findText(directory) == -1)
            directoryComboBox->addItem(directory);
        directoryComboBox->setCurrentIndex(directoryComboBox->findText(directory));
    }
}
rproffitt commented: Why do lines 24 and on look like line 1 up to 23? +15

Honestly, it would help if you could describe what the code does. A picture of the GUI woould help.