Settings dialog, using information from its parent window
If the SettingsDialog can only take a MainWindow as a parent in the constructor then declare it to be so:

SettingsDialog::SettingsDialog(MainWindow *parent) :
    QDialog(parent),
    ui(new Ui::SettingsDialog)
{


As for getting the type indeed passing it in explicitly is better.

void MainWindow::on_actionSettings_triggered()
{
    SettingsDialog * settings = new SettingsDialog(this, deviceType);

    settings-&gt;exec();
}


My MainWindow popups a SettingsDialog. The setting dialog need to hide certain fields if the connected device is certain type.

void MainWindow::on_actionSettings_triggered()
{
    SettingsDialog * settings = new SettingsDialog(this);

    settings-&gt;exec();
}


Now in SettingsDialog:

SettingsDialog::SettingsDialog(MainWindow *parent, DeviceType deviceType) :
    QDialog(parent),
    ui(new Ui::SettingsDialog)
{
    ui-&gt;setupUi(this);

    QSettings settings;

    if (deviceType == DEVICE_TYPE_B )
    {
        ui-&gt;comboBoxIP-&gt;setVisible( false );
    }
}