Checkbox and radiobutton with actions using QT designer

EdpaEdpa Posts: 46

I solved the problem with the creation of checkboxes and radiobuttons using QT designer (UI format).
The code works fine. Or it can be done more correctly? I used the signals - pressed() and (or) clicked()

var loader = new DzUiLoader();

var dialog = new DzDialog();

var dialogWgt = loader.load("C:/test.ui",dialog);

var a =0;

var b=0;

var checkbox = dialog.findChildOfWidget("checkBox"); // Find the button by its name

connect( checkbox, " clicked()",Checkboxfunction);

var radioButton = dialog.findChildOfWidget("radioButton"); // Find the button by its name

connect(radioButton, "pressed()", RadioButtonfunction );

dialog.exec();

//=====================================================

function Checkboxfunction()

{

// Test checked or unchecked

a =a+1;true;

if ( a&1 ) { print("checkbox");}

else { print("not marked");}

}

function RadioButtonfunction()

{

// Test checked or unchecked

b =b+1;true;

if ( b&1 ) { print("radiobutton");}

else {print("not checked");}

Post edited by Edpa on

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,871

    Are you wanting to do anything in response to the checks while the dialogue is displayed? If not you don't need to connect special functions, just read the state of the boxes/buttons off after the dialogue is closed (with OK rather than cancel if it appropriate). Connecting a signal to a slot is mainly for allowing you do soemthing while another process (in this case displaying a dialogue) is active.

    For example, you might have a box for a folder name and a Browse button beside it - you might then connect the Browse button being clicked to a function to get a new folder name, and if that was not cancelled you would update the value in the dialogue before exiting the function. On the other hand a set of radio buttons to add the folder selected as a Daz Studio, Poser, or Other Fomats content dierctory could be left until the dialogue was closed with an Accept and the final values of the name and the radio buttons were accessed from the dialogue object and then passed to a section of code to add the directory as specified.

  • EdpaEdpa Posts: 46

    Hi!

    Thanks! I saw when I have a dialogue, the variables (false and true) do not change. After the end of dialogue this worked normally. I thought it was a mistake :)

  • Richard HaseltineRichard Haseltine Posts: 100,871

    If you want the values during the dialogue's execution you should be able to get them by querying the widgets directly.

Sign In or Register to comment.