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. Is it possible to create template signals?
QtWS25 Last Chance

Is it possible to create template signals?

Scheduled Pinned Locked Moved Solved General and Desktop
signaltemplate
3 Posts 2 Posters 1.2k 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.
  • C Offline
    C Offline
    CJha
    wrote on 19 Apr 2022, 11:41 last edited by
    #1

    Is it possible to create a general template signal in a QObject subclass like this:

    signals:
    	template<typename T>
    	void templateSignal(const T& t);
    

    I tried and I get the error: The "QtRunWork" task returned false but did not log an error

    J 1 Reply Last reply 19 Apr 2022, 11:56
    0
    • C CJha
      19 Apr 2022, 11:41

      Is it possible to create a general template signal in a QObject subclass like this:

      signals:
      	template<typename T>
      	void templateSignal(const T& t);
      

      I tried and I get the error: The "QtRunWork" task returned false but did not log an error

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 19 Apr 2022, 11:56 last edited by J.Hilk
      #2

      @CJha the answer is generally no

      qmake, the magic behind signals and slots, can't run on the expanded templates, those are compiler intern stuff and qmake runs/parses your source files directly. IIRC

      So no, no templates with signals and slots.

      BUT
      there is verdigris, which should work with templates, but its a slightly different philosophy and a good bit more verbose.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      C 1 Reply Last reply 19 Apr 2022, 11:58
      3
      • J J.Hilk
        19 Apr 2022, 11:56

        @CJha the answer is generally no

        qmake, the magic behind signals and slots, can't run on the expanded templates, those are compiler intern stuff and qmake runs/parses your source files directly. IIRC

        So no, no templates with signals and slots.

        BUT
        there is verdigris, which should work with templates, but its a slightly different philosophy and a good bit more verbose.

        C Offline
        C Offline
        CJha
        wrote on 19 Apr 2022, 11:58 last edited by
        #3

        @J-Hilk Thanks :)

        1 Reply Last reply
        1

        2/3

        19 Apr 2022, 11:56

        • Login

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