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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on 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

    jsulmJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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

      SPlattenS 1 Reply Last reply
      0
      • jsulmJ jsulm

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

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on 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

        KroMignonK jsulmJ 2 Replies Last reply
        0
        • SPlattenS SPlatten

          @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.

          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on 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
          • SPlattenS SPlatten

            @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.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on 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

            • Login

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