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. [Solved] QAction setData with two data types
Forum Updated to NodeBB v4.3 + New Features

[Solved] QAction setData with two data types

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.4k 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.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    @QAction *act = new QAction("TEST");
    act.setData(QVariant(int, bool));@

    But I can't set QVariant with two data types. I try with struct & class Object but still errors.

    How can I do that?
    Thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Try @act.setData(QVariant(QMap<int, bool>))@

      Or QList, since the first T is int.

      (Z(:^

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zither
        wrote on last edited by
        #3

        @QMap<String,int>@
        So, can't make.

        But, int is unique, so I use QList...

        Thanks

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          QVariant holds one value, so you can not stuff two things into it.

          You might try a QPair to group two separate things into one entity.

          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