Пример #1
0
void DeviceEditDialog::buildGUI()
{
  QDialogButtonBox* buttonBox = new QDialogButtonBox(
      QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
  connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
  connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

  m_layout = new QFormLayout;
  setLayout(m_layout);
  m_layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);

  // QLabel for the warning text
  m_layout->addWidget(new TextLabel);

  m_protocolCBox = new QComboBox(this);
  m_layout->addRow(tr("Protocol"), m_protocolCBox);
  m_layout->addWidget(buttonBox);

  initAvailableProtocols(); // populate m_protocolCBox

  connect(
      m_protocolCBox,
      SignalUtils::QComboBox_currentIndexChanged_int(),
      this,
      &DeviceEditDialog::updateProtocolWidget);

  if (m_protocolCBox->count() > 0)
  {
    SCORE_ASSERT(m_protocolCBox->currentIndex() == 0);
    updateProtocolWidget();
  }
}
Пример #2
0
void
DeviceEditDialog::buildGUI()
{
    QLabel* protocolLabel = new QLabel(tr("Protocol"), this);
    m_protocolCBox = new QComboBox(this);

    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
            | QDialogButtonBox::Cancel, Qt::Horizontal, this);
    connect(buttonBox, &QDialogButtonBox::accepted,
            this, &QDialog::accept);
    connect(buttonBox, &QDialogButtonBox::rejected,
            this, &QDialog::reject);


    m_gLayout = new QGridLayout;

    // QLabel for the warning text
    m_gLayout->addWidget(new QLabel, 0, 0, 1, 2);

    m_gLayout->addWidget(protocolLabel, 1, 0, 1, 1);
    m_gLayout->addWidget(m_protocolCBox, 1, 1, 1, 1);
    //keep one row for m_protocolWidget
    m_gLayout->addWidget(buttonBox, 3, 0, 1, 2);

    setLayout(m_gLayout);

    initAvailableProtocols(); //populate m_protocolCBox

    connect(m_protocolCBox,  static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
            this, &DeviceEditDialog::updateProtocolWidget);

    if(m_protocolCBox->count() > 0)
    {
        ISCORE_ASSERT(m_protocolCBox->currentIndex() == 0);
        updateProtocolWidget();
    }
}