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. QJsonObject in header and QString/QVariant
QtWS25 Last Chance

QJsonObject in header and QString/QVariant

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 342 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.
  • N Offline
    N Offline
    NotYourFan
    wrote on last edited by
    #1

    Hey,

    im trying to create a QJsonObject.
    First Problem i want to create the QJsonObject in my Header …

    xyz.h:

    #include <QJsonObject>
    ...
    QJsonObject jsonView;
    

    xyz.cpp:

    jsonView{
    {hgz.name, hgz->value().first().valuemn.toString()}
    }
    

    i geht the following error:
    expected ';' before '{' token

    if i create the QJsonObject in the .cpp file everything is working fine.
    This version working:

    xyz.cpp

    QJsonObject jsonView{
    {hgz.name, hgz->value().first().valuemn.toString()}
    }
    

    i Need the JsonObject in my Controller so i should have global Access thats why i Need the JsonObject in my Header.

    The secound Problem:

    i want to create a QJsonObject with an String and a QVariant.

    {QString, QVariant}

    any Ideeas?

    jsulmJ JKSHJ 2 Replies Last reply
    0
    • N NotYourFan

      Hey,

      im trying to create a QJsonObject.
      First Problem i want to create the QJsonObject in my Header …

      xyz.h:

      #include <QJsonObject>
      ...
      QJsonObject jsonView;
      

      xyz.cpp:

      jsonView{
      {hgz.name, hgz->value().first().valuemn.toString()}
      }
      

      i geht the following error:
      expected ';' before '{' token

      if i create the QJsonObject in the .cpp file everything is working fine.
      This version working:

      xyz.cpp

      QJsonObject jsonView{
      {hgz.name, hgz->value().first().valuemn.toString()}
      }
      

      i Need the JsonObject in my Controller so i should have global Access thats why i Need the JsonObject in my Header.

      The secound Problem:

      i want to create a QJsonObject with an String and a QVariant.

      {QString, QVariant}

      any Ideeas?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @NotYourFan said in QJsonObject in header and QString/QVariant:

      QJsonObject jsonView;

      With a C++11 compiler you can initialise jsonView in the header.

      "i want to create a QJsonObject with an String and a QVariant" - what would be the content of that QVariant?

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

      1 Reply Last reply
      1
      • N NotYourFan

        Hey,

        im trying to create a QJsonObject.
        First Problem i want to create the QJsonObject in my Header …

        xyz.h:

        #include <QJsonObject>
        ...
        QJsonObject jsonView;
        

        xyz.cpp:

        jsonView{
        {hgz.name, hgz->value().first().valuemn.toString()}
        }
        

        i geht the following error:
        expected ';' before '{' token

        if i create the QJsonObject in the .cpp file everything is working fine.
        This version working:

        xyz.cpp

        QJsonObject jsonView{
        {hgz.name, hgz->value().first().valuemn.toString()}
        }
        

        i Need the JsonObject in my Controller so i should have global Access thats why i Need the JsonObject in my Header.

        The secound Problem:

        i want to create a QJsonObject with an String and a QVariant.

        {QString, QVariant}

        any Ideeas?

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @NotYourFan said in QJsonObject in header and QString/QVariant:

        i want to create a QJsonObject with an String and a QVariant.

        {QString, QVariant}

        any Ideeas?

        You cannot store a QVariant in a QJsonObject.

        You can store Booleans, numbers, strings, JSON arrays, or JSON objects in a QJsonObject.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        2

        • Login

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