Trouble with DzPopupMenu
kabexef
Posts: 75
In DS 4.21 I wanted to use DzPopupMenu.insertTextSubmenuItem to create a submenu within the popup and got the error 'TypeError: cannot call insertTextSubmenuItem(): argument 2 has unknown type `QMenu*' (register the type with qScriptRegisterMetaType())'.
wPopupMenu = new DzPopupMenu(dialog);
var wSubPopUp = new DzPopupMenu(dialog); wSubPopUp.insertTextItem("Title", 0);
wPopupMenu.insertTextItem("None", 0); wPopupMenu.insertTextSubmenuItem("Product", wSubPopUp, 1, 1);
Did I use it wrong?
Post edited by kabexef on
Comments
It is correct - it wants text, hence the method name, and you are giving it the menu object.
Sorry, but I can't figure it out ...
wPopupMenu.insertTextSubmenuItem("Product"); will result in
SyntaxError: too few arguments in call to insertTextSubmenuItem(); candidates are insertTextSubmenuItem(QString,QMenu*) insertTextSubmenuItem(QString,QMenu*,int) insertTextSubmenuItem(QString,QMenu*,int,int)
The method therefore requires a QMenu* object as the second argument.
wPopupMenu.insertTextSubmenuItem("Product", wSubPopUp); and
wPopupMenu.insertTextSubmenuItem("Product", "wSubPopUp.exec"); and
wPopupMenu.insertTextSubmenuItem("Product", "wSubPopUp"); result in
TypeError: cannot call insertTextSubmenuItem(): argument 2 has unknown type `QMenu*' (register the type with qScriptRegisterMetaType())
wPopupMenu.insertTextSubmenuItem("Product", wSubPopUp.exec); won't throw an error but also won't show a submenu.
Is there a small, working example somewhere?
Sorry, I was misreading
I am told you need to use wSubPopUp.getWidget()
wPopupMenu.insertTextSubmenuItem( "Product", wSubPopUp.getWidget(), 1, 1 );
It works :-). Thank a lot!
Keep an eye on the change log as this has been chnaged to remove the need for the getWidget() call - and there will be a sample showing how it works.
See http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/general_ui/simple_popupmenu_dialog/start