Note that there are some explanatory texts on larger screens.

plurals
  1. POqradiobutton issue
    primarykey
    data
    text
    <p>i have a problem with radio button.</p> <p>I've created a groupbox with two radio buttons and set it exclusive so when one is checked the other one is unchecked.</p> <p>when i check one it connects to a slot that as a function so it does an action, more specifically change the scale and transform the value from a Slider.</p> <p>the problem is when i clicked by mistake the already checked button, because even if it already checked it still connects to the function and the value of the slider is changed again, which i don't want.</p> <p>here's the code from them:</p> <pre><code>//Conect change from MM or PIXEL, making the change in the scale connect(ui-&gt;radioButton, SIGNAL(pressed())), this, SLOT(mm())); connect(ui-&gt;radioButton_2, SIGNAL(pressed()), this, SLOT(pixel())); </code></pre> <p>is there a way to block it when it has been already checked before?</p> <p>I'll post here the mm() and pixel() functions:</p> <pre><code>// Function to transform the slider scale from pixel to mm void planevolume::mm() { // Set the sliders ranges and connections // X Slider double xvaluem=ui-&gt;Slider-&gt;value(); ui-&gt;Slider-&gt;setRange(xmin, xmax/(256.0/3.0), 1.0/(256.0/3.0)); ui-&gt;Slider-&gt;setValue(xvaluem/(256.0/3.0)); ui-&gt;Slider-&gt;setScale(xmin, (xmax+1.0)/(256.0/3.0), ((xmax+1.0)/16.0)/(256.0/3.0)); connect(ui-&gt;Slider, SIGNAL(valueChanged(double)), ui-&gt;lcdNumber, SLOT(display(double))); // Y Slider double yvaluem=ui-&gt;Slider_2-&gt;value(); ui-&gt;Slider_2-&gt;setRange(ymin, ymax/(512.0), 1.0/(512.0)); ui-&gt;Slider_2-&gt;setValue(yvaluem/(512.0)); ui-&gt;Slider_2-&gt;setScale(ymin, (ymax+1.0)/512.0, (((ymax+1.0)/16.0)/512.0)); connect(ui-&gt;Slider_2, SIGNAL(valueChanged(double)), ui-&gt;lcdNumber_2, SLOT(display(double))); // Z Slider double zvaluem=ui-&gt;Slider_3-&gt;value(); ui-&gt;Slider_3-&gt;setRange(zmin, zmax/(64.0/3.0), 1.0/(64.0/3.0)); ui-&gt;Slider_3-&gt;setValue(zvaluem/(64.0/3.0)); ui-&gt;Slider_3-&gt;setScale(zmin, (zmax+1.0)/(64.0/3.0),(((zmax+1.0)/16.0)/(64.0/3.0))); connect(ui-&gt;Slider_3, SIGNAL(valueChanged(double)), ui-&gt;lcdNumber_3, SLOT(display(double))); } // Function to transform the slider scale from mm to pixel void planevolume::pixel() { // Set the sliders ranges and connections // X Slider double xvaluep=ui-&gt;Slider-&gt;value(); ui-&gt;Slider-&gt;setRange(xmin, xmax, 1.0); ui-&gt;Slider-&gt;setValue(xvaluep*(256.0/3.0)); ui-&gt;Slider-&gt;setScale(xmin, xmax+1.0, (xmax+1.0)/16.0); connect(ui-&gt;Slider, SIGNAL(valueChanged(double)), ui-&gt;lcdNumber, SLOT(display(double))); // Y Slider double yvaluep=ui-&gt;Slider_2-&gt;value(); ui-&gt;Slider_2-&gt;setRange(ymin, ymax, 1.0); ui-&gt;Slider_2-&gt;setValue(yvaluep*(512.0)); ui-&gt;Slider_2-&gt;setScale(ymin, ymax+1.0, (ymax+1.0)/16.0); connect(ui-&gt;Slider_2, SIGNAL(valueChanged(double)), ui-&gt;lcdNumber_2, SLOT(display(double))); // Z Slider double zvaluep=ui-&gt;Slider_3-&gt;value(); ui-&gt;Slider_3-&gt;setRange(zmin, zmax, 1.0); ui-&gt;Slider_3-&gt;setValue(zvaluep*(64.0/3.0)); ui-&gt;Slider_3-&gt;setScale(zmin, zmax+1.0, (zmax+1.0)/16.0); connect(ui-&gt;Slider_3, SIGNAL(valueChanged(double)), ui-&gt;lcdNumber_3, SLOT(display(double))); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload