Trouble with DzPopupMenu

kabexefkabexef Posts: 76

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

  • Richard HaseltineRichard Haseltine Posts: 100,882

    It is correct - it wants text, hence the method name, and you are giving it the menu object.

  • kabexefkabexef Posts: 76
    edited May 31

    Sorry, but I can't figure it out ...

    wPopupMenu = new DzPopupMenu(dialog);
    
    var wSubPopUp = new DzPopupMenu(dialog);
    
    wSubPopUp.insertTextItem("Title");
    
    wPopupMenu.insertTextItem("None");
    
    

    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?

    Post edited by kabexef on
  • Richard HaseltineRichard Haseltine Posts: 100,882

    Sorry, I was misreading

  • Richard HaseltineRichard Haseltine Posts: 100,882

    I am told you need to use wSubPopUp.getWidget()

    wPopupMenu.insertTextSubmenuItem( "Product", wSubPopUp.getWidget(), 1, 1 );

  • kabexefkabexef Posts: 76

    Richard Haseltine said:

    I am told you need to use wSubPopUp.getWidget()

    wPopupMenu.insertTextSubmenuItem( "Product", wSubPopUp.getWidget(), 1, 1 );

    It works :-). Thank a lot!

  • Richard HaseltineRichard Haseltine Posts: 100,882

    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.

Sign In or Register to comment.