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 get a long variable from QVariant
Forum Updated to NodeBB v4.3 + New Features

How to get a long variable from QVariant

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 268 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.
  • P Offline
    P Offline
    PMime
    wrote on 26 Apr 2023, 14:40 last edited by
    #1

    When the type of a QVariant variable is QMetaType::Long, how can I get a C++ long variable?

    QVariant offers the method toLongLong, but the result is a qlonglong variable. Is it possible that toInt would be equivalent to toLong?

    C 1 Reply Last reply 26 Apr 2023, 15:46
    0
    • P PMime
      26 Apr 2023, 14:40

      When the type of a QVariant variable is QMetaType::Long, how can I get a C++ long variable?

      QVariant offers the method toLongLong, but the result is a qlonglong variable. Is it possible that toInt would be equivalent to toLong?

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 26 Apr 2023, 15:46 last edited by Christian Ehrlicher
      #2

      Then use QVariant::value<long>(). But since sizeof(long long) = sizeof(long) on all 64 bit platforms - why do you need it?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3

      1/2

      26 Apr 2023, 14:40

      • Login

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