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. Connect return of a method to signal - possible?
Forum Updated to NodeBB v4.3 + New Features

Connect return of a method to signal - possible?

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

    Hi Qt-fans,

    I started some time ago with Qt (in PySide) and working now with C++ (where I am new - more or less). And I want to request data from TheMovieDB API with a getPopularMovies() method that should return a list of "MovieObjects" - they are holding just some arguments (Title, Image path ...) and have some get/set methods.

    My problem is the following:
    To do the request I use QNetworkManager's get method, which works pretty well, but due to the async nature it seems you should/have to connect the finished() signal to a SLOT. So I can't do the request and everything else (like parsing response) in one method. So I connected it to an evauate slot, that reads the JSON data from QNetworkReply and creates a list of MovieObjects. After they are created a finished() signal I implemented is emited.

    It would be great, if I could use return in getPopularMovies(), depending on my finished signal. Say something like that: connect(this, SIGNAL(myFinishedSignal), return <My list of objects>)

    Is something like that possible?

    Or do I need another function, to get the list? So that I call first searchPopularMovies() and than after this is finished a getPopularMovies() method?

    Thanks in advance, AlphaX2.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can't do that like that, signals only have void as return type and also no implementation.

      What you can do however is emit a signal with your MovieObjects list as a parameter.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - 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