CheckBox doesn't toggle if placed in a specific place in QGridLayout



  • Hello guys,

    I've written this program as a simulation for my PhD experiment. It represents the reaction of the magnetic moments of a Caesium gas under magnetic fields. Please check the program under the link.

    http://www.4shared.com/zip/NJJVf5nb/Blochsim.html

    The problem is, that the CheckBox labeled "Show Axes" doesn't toggle when clicked. I thought in the beginning it's some kind of feed back through the program, because there are many connections between the objects. But then I just changed the position of that widget and it worked.

    Could anyone please explain how this could be possible? Please check the code out. What kind of conflict could this be?

    Thank you for any efforts.

    This is the cpp file of the class of the widget that contains the CheckBox. Now to make the CheckBox work, all we have to do is change the line

    @mainGridLayout->addWidget(axesVisibilityCheckBox,0,0,1,1);@
    

    to

    @mainGridLayout->addWidget(axesVisibilityCheckBox,8,0,1,1);@
    

    @
    #include "optionswidget.h"
    #include "mainwindow.h"

    OptionsWidget::OptionsWidget(QWidget *parent) :
    QWidget(parent)
    {
    this->setControlsBoundaries();
    this->createControls();
    this->setControlsCaptions();
    this->setControlsInitialValues();
    this->doConnections();
    this->createLayout();
    }

    void OptionsWidget::doConnections()
    {

    connect(axesVisibilityCheckBox,SIGNAL(toggled(bool)),((MainWindow*)parentWidget())->openGLApp,SLOT(setShowAxesBoolSlot(bool)));
    ...
    

    }
    void OptionsWidget::setControlsInitialValues()
    {
    axesVisibilityCheckBox->setChecked(1);
    ...
    }
    void OptionsWidget::setControlsBoundaries()
    {
    ...
    }
    void OptionsWidget::setControlsCaptions()
    {
    axesVisibilityCheckBox->setText(tr("Show Ax&es"));
    ...
    }
    void OptionsWidget::createControls()
    {
    axesVisibilityCheckBox = new QCheckBox(this);
    ...
    }
    void OptionsWidget::createLayout()
    {
    mainGridLayout = new QGridLayout;

    mainGridLayout->addWidget(axesVisibilityCheckBox,0,0,1,1); //here
    mainGridLayout->addWidget(rotateAxesCheckBox,0,1,1,1);
    mainGridLayout->addWidget(rotateAxesFreqControl->getLabel(),0,2,1,1);
    mainGridLayout->addWidget(rotateAxesFreqControl->getSlider(),0,3,1,1);
    mainGridLayout->addWidget(rotateAxesFreqControl->getSpinBox(),0,4,1,1);
    mainGridLayout->addWidget(axesOpacityControl->getLabel(),0,5,1,1);
    mainGridLayout->addWidget(axesOpacityControl->getSlider(),0,6,1,1);
    mainGridLayout->addWidget(axesOpacityControl->getSpinBox(),0,7,1,1);
    
    mainGridLayout->addWidget(constantFieldVisibilityCheckBox,2,0,1,1);
    mainGridLayout->addWidget(constantFieldEnableCheckBox,2,1,1,1);
    mainGridLayout->addWidget(constantFieldAmplControl->getLabel(),2,2,1,1);
    mainGridLayout->addWidget(constantFieldAmplControl->getSlider(),2,3,1,1);
    mainGridLayout->addWidget(constantFieldAmplControl->getSpinBox(),2,4,1,1);
    mainGridLayout->addWidget(constantFieldDirControl->getLabel(),2,5,1,1);
    mainGridLayout->addWidget(constantFieldDirControl->getSlider(),2,6,1,1);
    mainGridLayout->addWidget(constantFieldDirControl->getSpinBox(),2,7,1,1);
    
    mainGridLayout->addWidget(rotatingFieldVisibilityCheckBox,1,0,1,1);
    mainGridLayout->addWidget(rotatingFieldEnableCheckBox,1,1,1,1);
    mainGridLayout->addWidget(rotatingFieldFreqControl->getLabel(),1,2,1,1);
    mainGridLayout->addWidget(rotatingFieldFreqControl->getSlider(),1,3,1,1);
    mainGridLayout->addWidget(rotatingFieldFreqControl->getSpinBox(),1,4,1,1);
    mainGridLayout->addWidget(rotatingFieldAmplControl->getLabel(),1,5,1,1);
    mainGridLayout->addWidget(rotatingFieldAmplControl->getSlider(),1,6,1,1);
    mainGridLayout->addWidget(rotatingFieldAmplControl->getSpinBox(),1,7,1,1);
    
    experimentingLayout->addWidget(resetSimulationPushButton,0,0,1,1);
    experimentingLayout->addWidget(resetRotatingFramePushButton,1,0,1,1);
    experimentingLayout->addWidget(resetMagnetisationZPushButton,0,1,1,1);
    experimentingLayout->addWidget(resetMagnetisationXYPlanePushButton,1,1,1,1);
    experimentingLayout->addWidget(ramseyPulsePushButton,0,2,1,1);
    experimentingLayout->addWidget(piOverTwoPulsePushButton,1,2,1,1);
    experimentingLayout->addWidget(rabiOscillationPushButton,0,3,1,1);
    experimentingLayout->addWidget(larmorTheoremCheckBox,1,3,1,1);
    experimentingLayout->addWidget(sinusoidalRFCheckBox,0,4,1,1);
    experimentingLayout->addWidget(pauseSimulationCheckBox,1,4,1,1);
    
    experimentingGroupBox->setLayout(experimentingLayout);
    
    mainGridLayout->addWidget(experimentingGroupBox,3,0,1,8);
    setLayout(mainGridLayout);
    

    }
    OptionsWidget::~OptionsWidget()
    {

    delete axesVisibilityCheckBox;
    ...
    

    }
    ...

    @



  • Guys, come on. If this would be a bug in Qt please say! I have no idea what this could be...! Any help is highly appreciated.



  • Patience is a virtue.
    Little more than 8 hours - nobody here is in front of the interwebs 24/7. Bumping a topic is acceptable after waiting a few days, not hours. Thanks.



  • :'(

    Apparently I have to go to report this as a bug. But I can't understand the full dimensions of the problem...!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.