Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to check a variant valid or not in qml?

How to check a variant valid or not in qml?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 657 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.
  • H Offline
    H Offline
    Hit Tiger Tonight
    wrote on last edited by
    #1

    How to check a variant valid or not in qml?
    The QVariant has an isValid() method to determine it is valid or not. But pass a QVaraint to qml method or property, the isValid() seems disappeared.
    Is anyone know how to check the variant in qml?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fromis_9
      wrote on last edited by
      #2

      Use 'undefined' instead.

      var invalidValue = backend.GetInvalidQVar();
      if (invalidValue == undefined) {
        console.log("Invalid");
      }
      else {
        console.log("Valid");
      }
      
      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