[Gambas-user] How can I instantiate a virtual class?
Benoît Minisini
g4mba5 at gmail.com
Fri Sep 14 09:44:48 CEST 2018
Le 14/09/2018 à 04:16, Me a écrit :
>
> Well, I have gotten soooooo close, but. :-(
> With everyones' input (and a lot of QT doc searching), here's what I have found, noting
> that the final step fails so the whole thing is moot really.
>
> 1. I can't re-order an existing menu but it is possible to insert a new menu at a
> specific position by copying all the subsequent menu items from the insertion point
> in the parent menu out to an array, creating the target menu item in the parent and then
> re-adding the copied out items. This got around the virtual class problem with .Menu.Children
> as I can use Me.Children[index].
>
> 2. I can't just "copy" those subsequent menu items, I have to unmarshall all their properties
> into a Variant[] and then create new menu items in the parent. This has the drawback that
> the copied items cannot have children, but that is outside the scope of my immediate goal.
> The reason they have to be unmarshalled is that when I delete the original menu items it renders
> any "copy" of the menu invalid.
>
> 3. To do the above I created a MenuManager class that knows about the current form's
> menus and can manipulate them. It also knows about a "Position" property for the specific
> menus I am looking at.
>
> 4. The whole idea falls over because the menu manager does its stuff when the menu is created.
> Unfortunately, this seems to be too early in the form loading/startup when the .form file has not been
> read. I have had that problem before with some custom controls and solved that by deferring the
> mechanism until the control_Activate event fired, Menus don't have such an event, nor any other
> suitably delayed event I could leverage.
>
> Such is life. Anyway I have used up the client's budget for this so I'll be puttting it away for now.
>
> One thing I have noticed though. The QT4/5 QWidget classes both have an
> "insertAction(QAction * before, QAction * action)" function. My shallow reading of the docs leads me
> to ask the question, "If the CMenu.cpp class used that instead
> of addAction() in Menu_new, with an optional Position parameter could that get rid of the need to
> rebuild the whole menu?" (or does &^*%E$$ gtk preclude that as an alternative?). Note the only thing
> I can do with C++ is spell it.
>
> regards
> b
>
AFAIK, GTK+ allows to insert a menu at a specific position, and to move
them. But QT only allows to insert a menu at a specific position. You
can't move them after they have been inserted.
--
Benoît Minisini
More information about the User
mailing list