Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [SOLVED] how to create a map of actions
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] how to create a map of actions

Scheduled Pinned Locked Moved C++ Gurus
4 Posts 3 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fluca1978
    wrote on last edited by
    #1

    Hi,
    I've got some problems creating a map of actions. In my code I've code something like the following:

    @QAction* actionUserManagement = new QAction( this );
    actionUserManagement->setText( tr("Manage users") );
    ...
    QAction& currentAction = *actionUserManagement;
    actionsMap->insert( QString("userview"), currentAction );@

    but this is not working, it seems the map is calling a QAction( QAction) constructor which is protected. How can I solve this?
    Thanks

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      What's "actionMap"? Why are you using a reference to a QAction?

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        You can not create a QMap<QAction>. Containers need their contents to be default constructable and copyable, and QAction does not satisfy those requirements (nor does any other QObject subclass). You can however create a QMap<QAction*> without problems, or even use one of the (shared) pointer classes in your map.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fluca1978
          wrote on last edited by
          #4

          Thanks, using the QAction* works for me!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved