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 285 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 10 Jul 2024, 11:56 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
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 10 Jul 2024, 12:01 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 10 Jul 2024, 12:29
      3
      • C Christian Ehrlicher
        10 Jul 2024, 12:01

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

        A Offline
        A Offline
        Alxi11
        wrote on 10 Jul 2024, 12:29 last edited by
        #3

        @Christian-Ehrlicher Thanks a lot!

        1 Reply Last reply
        0
        • A Alxi11 has marked this topic as solved on 10 Jul 2024, 12:29
        • C Christian Ehrlicher
          10 Jul 2024, 12:01

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

          S Offline
          S Offline
          SimonSchroeder
          wrote on 11 Jul 2024, 06:32 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

          4/4

          11 Jul 2024, 06:32

          • Login

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