Answer the question
In order to leave comments, you need to log in
Qt. Is it possible to create a dynamic assembly of the context menu?
Good day.
There are heirs from QGraphicsItem, various. Behind each graphic object there is a logical class. At first I made a context menu for each graphical object and everything seemed to work, although I had to write a bunch of connections.
Now the situation has changed.
1. Because all logical and graphical objects live in the library, which is assembled without widgets, you cannot call a dialog box from the menu. But you must.
2. Depending on the type of program (may vary), you need different types of context menu.
The question is, where is it better to take out the creation of the menu and how to assign it?
I tried to define the context menu in the scene, and check whether the cursor got into the graphic object or not. In principle, it works, it remains only at this moment to understand what type of graphic object and, based on this, display the menu. But in the scene itself, it is not desirable to write slots, include descriptions of logic, and so on. Is it possible somewhere aside at the start of the program to assemble the menu, and then work out in the scene. if the type of the graphic element is number 1, then we take menu1 and show it.
Thanks in advance for any advice.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question