Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CheckBox doesn't toggle if placed in a specific place in QGridLayout
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheDestroyer
    wrote on last edited by
    #1

    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;
    ...
    

    }
    ...

    @

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TheDestroyer
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        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.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TheDestroyer
          wrote on last edited by
          #4

          :'(

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved