Thank you, it works. But it should work with Application
No it cannot work like that since WS.CreateHandle() expects TCustomForm as owner.
class function TQtWSMenu.CreateHandle(const AMenu: TMenu): HMENU;
var
MenuBar: TQtMenuBar;
Menu: TQtMenu;
begin
{ If the menu is a main menu, there is no need to create a handle for it.
It's already created on the window }
if (AMenu is TMainMenu) and (AMenu.Owner is TCustomForm) then <------------ See this
begin
MenuBar := TQtMainWindow(TCustomForm(AMenu.Owner).Handle).MenuBar; <------------- and then this
Result := HMENU(MenuBar);
end
else if (AMenu is TPopUpMenu) then
begin
Menu := TQtMenu.Create(AMenu.Items);
Menu.AttachEvents;
Result := HMENU(Menu);
end;
{$ifdef VerboseQt}
Write('[TQtWSMenu.CreateHandle] ');
if (AMenu is TMainMenu) then Write('IsMainMenu ');
WriteLn(' Handle: ', dbghex(Result), ' Name: ', AMenu.Name);
{$endif}
end;
While creating menu handle parent is still unassigned, so owner is only solution.
Maybe I can add check for Application as owner, but in that case that menu should be treated only as TApplication.MainForm child.