DAZ and QT( from UI file) widgets - how to combine work?

YudinEdYudinEd Posts: 90

QT widgets work well with signals. But how to work together with DAZ widgets  and widgets from  UI file? For example, to put the DAZ button into QT Group box or in tab widget (and so on).

var loader = new DzUiLoader();var dialog = new DzDialog();var dialogWgt = loader.load("C:/untitled.ui",dialog);var groupBox=dialog.findChildOfWidget("groupBox"); // QT widget from UI filevar But=new DzPushButton(groupBox) // DAZ widget into QT widget from UIdialog.exec(); 

This code gives an error "general\dzscript.cpp(658): Unhandled error while executing script."

What I need to do to link different widgets - DAZ and QT?

 

Post edited by YudinEd on

Comments

  • jag11jag11 Posts: 885

    Just use dialogWgt with findChildOfWidget() or even better getChildrenOfWidget.

  • YudinEdYudinEd Posts: 90

    My script example has "findChildOfWidget()". :) The problem was precisely in the presence of this function.

    OK, I'll try "getChildrenOfWidget"

  • jag11jag11 Posts: 885
    YudinEd said:

    My script example has "findChildOfWidget()". :) The problem was precisely in the presence of this function.

    In the code you posted you wrote

    dialog.findChildOfWidget("groupBox"); 

    should be:

    dialogWgt.findChildOfWidget("groupBox");

    Reason is you are searching for a child of the just loaded UI widget, which is dialogWgt, not dialog.

  • YudinEdYudinEd Posts: 90

     

    jag11 said:

    should be:

    dialogWgt.findChildOfWidget("groupBox");

    Reason is you are searching for a child of the just loaded UI widget, which is dialogWgt, not dialog.

    I understood it. This is logical, but wrong. :)  This option gives an error "general\dzscript.cpp(658): Unhandled error while executing script."

    dialog.findChildOfWidget - it's true. But it works strange. Not all functions work.

    To example - hide(), show(true) or .text="..."  -function normally with  QT widgets.

    But  .x or  .y don't work

    I can not put DAZ objects into a QT tab or in QT group too.

     

     

  • jag11jag11 Posts: 885

    I have not tried using DAZ objects when working with UI files, I design the dialog the way I need it and then connect the event handlers. The objects in UI file are pure QT widgets, so they might have different properties than DzWidgets, for ex: to move a DzButton you just need to set x and y properties, but for QWidgets you need to extract the geometry(QRect) property and then set x and y properties.

    That's how I did the Sun-Sky Time for Iray script. Although the UI file is decrypted before loading.

  • YudinEdYudinEd Posts: 90
    edited April 2018

    I did the script style with  the UI designer.

    But in the process of working on the script  I had to make a list of figures and props from the scene using cycle for... to create group of checkboxes and objects names. 

    DAZ widgets and script code below  were convenient for this case (I found the script basis here perhaps by Richard Haseltine ). I do not know how to do this using only QT widgets..

    But I do not want to give up the general design made in UI designer.

    for ( n = 0 ; n < items.length ; n++ ) { // Skip bones of figures, lights and cameras  if ( items[ n ].inherits( "DzBone" ) ) {  continue; }	 if ( items[ n ].getObject() ) { 	 wBtn[n] = new DzCheckBox( wBtnGrp );		wBtn[n].text =items[ n ].getLabel()				 }}

     

    Post edited by YudinEd on
  • YudinEdYudinEd Posts: 90
    edited May 2018

    I can not solve another problem too. 

    When DAZ reads *. ui, it does not find the path to the pictures. It requires a full path to the images in *.ui.

    What to do, because each user has his own path to pictures? Is it possible to change something in the script or into the UI  file ?

    Post edited by YudinEd on
  • jag11jag11 Posts: 885

    Use relative paths like in "./".

    There are alternatives some alternatives you can use, like:

    1. Load the *.UI, load the image, find the control and assign the image.
    2. Create a template *.UI file by modifiying every image reference to the form "%PATH%/assets/circle-button.png", the first run ever of your script save to a temp file with the %PATH% replaced. And then load as usual.

    HTH

     

  • YudinEdYudinEd Posts: 90

    jag11, thanks very much. I'll try it.

  • YudinEdYudinEd Posts: 90
    YudinEd said:

    QT widgets work well with signals. But how to work together with DAZ widgets  and widgets from  UI file? For example, to put the DAZ button into QT Group box or in tab widget (and so on).

    var loader = new DzUiLoader();var dialog = new DzDialog();var dialogWgt = loader.load("C:/untitled.ui",dialog);var groupBox=dialog.findChildOfWidget("groupBox"); // QT widget from UI filevar But=new DzPushButton(groupBox) // DAZ widget into QT widget from UIdialog.exec(); 

    This code gives an error "general\dzscript.cpp(658): Unhandled error while executing script."

    What I need to do to link different widgets - DAZ and QT?

     

     

    I tried to combine widgets (DAZ+QT) in this way. I could not invent another :)

     

    tabW = dialog.findChildOfWidget("tabWidget");   // Find the button by its nametabW.currentIndex = 0 // open tab with index #0 (first)connect(tabW,"currentChanged (int)",But1Func)   // if tab #0 closes var gr = new DzGroupBox( dialog );    // DAZ group box with DAZ button for QT tab #0but=new DzPushButton(gr)dialog.exec();function But1Func(){	gr.hide()	if (tabW.currentIndex==0)gr.show()		}

     

Sign In or Register to comment.