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. QVariant isArray ?
Forum Updated to NodeBB v4.3 + New Features

QVariant isArray ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 562 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.
  • S Offline
    S Offline
    SPlatten
    wrote on 17 Feb 2022, 11:59 last edited by
    #1

    Is there a generic way to identify if the data assigned to a QVariant is an array?

    I know there is the type function, but I'm looking for something that may already exist before I re-invent the wheel.

    Kind Regards,
    Sy

    J 1 Reply Last reply 17 Feb 2022, 12:26
    0
    • S SPlatten
      17 Feb 2022, 11:59

      Is there a generic way to identify if the data assigned to a QVariant is an array?

      I know there is the type function, but I'm looking for something that may already exist before I re-invent the wheel.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 17 Feb 2022, 12:26 last edited by
      #2

      @SPlatten What do you mean by array? QByteArray?
      And what is the problem with type()?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 17 Feb 2022, 12:42
      0
      • J jsulm
        17 Feb 2022, 12:26

        @SPlatten What do you mean by array? QByteArray?
        And what is the problem with type()?

        S Offline
        S Offline
        SPlatten
        wrote on 17 Feb 2022, 12:42 last edited by
        #3

        @jsulm , I was looking for a generic way of determining if the data stored in the QVariant was singular or multiplies like a QByteArray.

        I just wanted to know if there was already a way of determining this.

        Kind Regards,
        Sy

        K J 2 Replies Last reply 17 Feb 2022, 12:51
        0
        • S SPlatten
          17 Feb 2022, 12:42

          @jsulm , I was looking for a generic way of determining if the data stored in the QVariant was singular or multiplies like a QByteArray.

          I just wanted to know if there was already a way of determining this.

          K Offline
          K Offline
          KroMignon
          wrote on 17 Feb 2022, 12:51 last edited by
          #4

          @SPlatten said in QVariant isArray ?:

          I was looking for a generic way of determining if the data stored in the QVariant was singular or multiplies

          Short answer: no

          Long answer: it depends how you are using it. QVariant::type() will return an enum value to let you know what is the type of the stored value.
          To be able to store a value into a QVariant, this value has to be already known or register with Q_DECLARE_METATYPE()
          QVariant::type() will let you know the variable type, and then you can get the according value with QVariant::value<TypeOfTheVariable>()

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          1 Reply Last reply
          0
          • S SPlatten
            17 Feb 2022, 12:42

            @jsulm , I was looking for a generic way of determining if the data stored in the QVariant was singular or multiplies like a QByteArray.

            I just wanted to know if there was already a way of determining this.

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 17 Feb 2022, 12:52 last edited by
            #5

            @SPlatten OK, now I understand.
            I don't think there is already built-in functionality for this.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            1/5

            17 Feb 2022, 11:59

            • Login

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