List Views?

Is there example script code showing how to populate a list view with nodes?

I would like to re-create this partcular list view.  It lists a hierarchy of nodes with checkmarks by them.  And there is no visible divider in the column header:

https://i.imgur.com/iqlVrNh.png

No basic examples about list views can be found in the docs:

http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/listview_dz
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/checklistitem_dz

Comments

  • A lot of those are custom objects built from multiple sub-objects, rather than stock objects. I don't know if that applies here but it would not be a surprise.

  • Seven193Seven193 Posts: 1,096

    Well, I had to piece together from some random scripts, but got something working.

    Found out how to get a single header with no divider line:
    treeWidget1.header().setStretchEnabled(true,0);

    https://i.imgur.com/PwKqup8.png


    A more complete example:

    function
    Add_Tree_Item(treeView, nodeText, bCheckFlag) {

     // create checked item
     var wTreeItem = new DzCheckListItem( treeView, DzCheckListItem.CheckBox );

     // Set the text
     wTreeItem.setText( 0, nodeText );

     // Expand the item
     wTreeItem.open = true;

     // checked (Boolean)
     wTreeItem.on = bCheckFlag;

     return wTreeItem;
    }

    (function() {

     // Get the current style
     var oStyle = App.getStyle();

     // Get pixel metrics from the style
     var nMargin   = oStyle.pixelMetric( "DZ_GeneralMargin" );
     var nStepSize = oStyle.pixelMetric( "DZ_TreeStepSize" );

     /////////////////////////////////////

     // Create Dialog Box
     var wDlg = new DzDialog();
     wDlg.width = 276;
     wDlg.height = 308;
     wDlg.caption = "ListView Test";

     var treeWidget1 = new DzListView( wDlg );
     treeWidget1.setGeometry( 10, 30, 251, 231 );
     treeWidget1.addColumn( "Nodes" );

     treeWidget1.setSorting( -1 );
     treeWidget1.header().setStretchEnabled(true,0);

     treeWidget1.itemMargin   = nMargin;
     treeWidget1.treeStepSize = nStepSize;

     Add_Tree_Item( treeWidget1, "Item1", true );
     Add_Tree_Item( treeWidget1, "Item2", true );
     Add_Tree_Item( treeWidget1, "Item3", true );

     var pushButton1 = new DzPushButton( wDlg );
     pushButton1.setGeometry( 100, 270, 75, 25 );
     pushButton1.text = "Accept";
     pushButton1.objectName = 'pushButton1';
     wDlg.setAcceptButton(pushButton1);

     var pushButton2 = new DzPushButton( wDlg );
     pushButton2.setGeometry( 180, 270, 75, 25 );
     pushButton2.text = "Cancel";
     pushButton2.objectName = 'pushButton2';
     wDlg.setRejectButton(pushButton2);

     /////////////////////////////////////

     // Display the dialog box
     var bResult = wDlg.exec();

     if(bResult) {
     }  
     else {
     }

    })();

     

  • Richard HaseltineRichard Haseltine Posts: 101,805
    edited December 2024

    I am told that using DzBasicDialog, rather than DzDialog, with its AddWidget() method will be better as you will get auto-adjustment and default buttons.

    If the random scripts included the samples make sure that you respect the license terms, and likewise for any other scripts you use.

    Post edited by Richard Haseltine on
  • Seven193Seven193 Posts: 1,096
    edited December 2024

    Why does Daz include QT Designer in the Daz Studio package if not to use it to create dialogs?  I cannot visualize an auto-adjusting dialog, nor can I find any good examples.

    And what if the script was generated by AI like chatGPT?  Not that it was, but it's a possibility.

    Post edited by Seven193 on
  • The samples use Basic Dialogue, rather than Dialogue. As far as I know Qt designer is part of the standard footprint, but in any event I don't think it was "never use dzDialog but rather "DzBasicDialog" is better for this kind of thing.

  • It isn't soemthing I have done, but apaprently Qt Designer gives UI files which then need to be accessed through another object - I think http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/uiloader_dz

    Don't forget that if you point  ChatGPT to the Daz Scripting docs it is still bound by the terms of any samples it samples.

  • Seven193 said:

    Why does Daz include QT Designer in the Daz Studio package if not to use it to create dialogs?  I cannot visualize an auto-adjusting dialog, nor can I find any good examples.

    And what if the script was generated by AI like chatGPT?  Not that it was, but it's a possibility.

    I've never not used Designer to make dialogs, and set up custon build steps in VS to generate the ui.h and .moc files. I've never encountered any issues.

  • Seven193Seven193 Posts: 1,096
    edited December 2024

    I mentioned QT Designer because it creates all of its widgets with fixed geometry (pixel) values.  From a typical .ui file:

      <widget class="QPushButton" name="pushButton_2">
       <property name="geometry">
        <rect>
         <x>100</x>
         <y>140</y>
         <width>75</width>
         <height>25</height>
        </rect>
       </property>
       <property name="text">
        <string>Accept</string>
       </property>
      </widget>

    And I did come across some forum comment mentioning fixed values are bad for high DPI monitors.  So, does that mean using QT Designer is now bad practice for designing dialogs?

     

    Post edited by Seven193 on
  • I didn't think of that. I wonder if the behavior you researched is also true for the versions of Qt that support high DPI?

Sign In or Register to comment.