Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can a signal have a QJsonDocument argument?
Qt 6.12 LTS is out! See what's new in the release blog

Can a signal have a QJsonDocument argument?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    @
    class QReply : public QObject {
    Q_OBJECT
    signals:
    void finished(QJsonDocument* json);
    void finished(QJsonDocument json);
    };
    @

    I wonder what type the json arg should be? A pointer? If so, who deletes it and when? Since QJsonDocument is not a QObject I cannot deleteLater() it. So I guess I could use a QJsonDocument as argument and copy ctor will take care of transfering the internal state of the Json object to the slots?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      both are applicable.
      Where do you create the document object?
      Since your QReply class emits the signal it may manage the pointer and delete it in it's constructor.
      It depends on your application logic if only the value for the receiver counts of if you need the pointer to modify this specific object.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      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
      • Unsolved