Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use Q_GLOBAL_STATIC with QMap

How to use Q_GLOBAL_STATIC with QMap

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 281 Views
  • 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.
  • A Offline
    A Offline
    Alxi11
    wrote on last edited by
    #1

    I want to write code like this:

    Q_GLOBAL_STATIC(QMap<QString, MyType>, myTypeList>
    

    But the comma in QMap just confuses Q_GLOBAL_STATIC. What can I do about this? Maybe just use non-POD global statics?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Typedef the QMap to a new type and use this in Q_GLOBAL_STATIC

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A S 2 Replies Last reply
      3
      • Christian EhrlicherC Christian Ehrlicher

        Typedef the QMap to a new type and use this in Q_GLOBAL_STATIC

        A Offline
        A Offline
        Alxi11
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thanks a lot!

        1 Reply Last reply
        0
        • A Alxi11 has marked this topic as solved on
        • Christian EhrlicherC Christian Ehrlicher

          Typedef the QMap to a new type and use this in Q_GLOBAL_STATIC

          S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #4

          @Christian-Ehrlicher said in How to use Q_GLOBAL_STATIC with QMap:

          Typedef the QMap

          I always found typedef at least a little confusing. With modern C++ we can use using to "typedef" new types.

          I would assume that also putting QMap<QString, MyType> into parentheses, i.e. ( and ), would work because this is a macro to be expanded.

          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