Is it a good practice or good idea to have a stock of actions?



  • Hi my friends, today I come with the following questions.

    I am trying to create a basic structure type RCP but extensible by means of plugins for my applications and thus not having to copy and paste and modify some other things before starting a new project.

    The doubts are the following:

    1-. Is it a good practice or good idea to have a stock of actions for the application? (so there are actions that are needed in different contexts, but the exact same thing must be performed)
    2-. On the other hand and in the same order of ideas, it would be a good practice or good idea to work with a factory of actions (factory pattern)?


  • Qt Champions 2017

    Hi
    QAction is meant for the exact use case of multiple ways
    for user to activate a command and at the same time make it easy to manage its
    status without having to manually handle all the different contexts.

    http://doc.qt.io/qt-5/qaction.html

    So if you mean if its ok to have a list actions to reuse for menus and toolsbars
    then yes, surely.

    Regarding the factory pattern. If you plan on subclassing QAction to add custom data or
    features so the contexts would be handed mixed types of QActions, it might make sense, but outside that , im not really sure what you would gain from it ?

    You plan that the plugins can ask MainApp about a list of Action or anything like that?


  • Lifetime Qt Champion

    Hi,

    Shouldn't rather your plugins provide a set of action to do whatever they provide ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.