单选按钮永远不会出现

时间:2018-11-07 08:49:27

标签: c++ qt

使用以下代码在组框中创建单选按钮,没有任何结果。有点背景:在我的显示中,每个对象都有多个变体,用户必须选择要显示哪个(或全部)。我错过了什么更新/刷新命令,或者出了什么问题?

for(int i = 0; i < MAX_NUM_VARIANTS+1; i++)
    {
        m_variantButtons[i] = new QRadioButton();
        m_variantButtons[i]->setText(QString::number(i));
        m_variantButtons[i]->setObjectName(QString("m_pbDisplayVariant%1").arg(i));

        QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(true);
        m_variantButtons[i]->setSizePolicy(sizePolicy);

        ((QGridLayout*)(ui.m_groupBoxVariants->layout()))->addWidget(m_variantButtons[i], 1, i);
        ((QGridLayout*)(ui.m_groupBoxVariants->layout()))->update();
        connect(m_variantButtons[i], SIGNAL(clicked(bool)), this, SLOT(updateDisplaySettings()));
        m_variantButtons[i]->setVisible(true);
    }
    ((QWidget*)(ui.m_groupBoxVariants))->updateGeometry();

0 个答案:

没有答案