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 define a macro function with included the signals key words?
Forum Updated to NodeBB v4.3 + New Features

how to define a macro function with included the signals key words?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 206 Views 2 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    when I used the macro liked this

    #define FUNCTION(NAME)\
    signals:\
    void on##NAME##Function();
    

    it dosent work. so is it possible that the macro could include the signals key words?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      CassD
      wrote on last edited by
      #2

      hi

      doesn't work this way. There's no need of macros for this. the onSomeEvent method is an autoconnection pattern that allows you to create a method that acts like a slot and autoconnects to the matching signal.
      just name your signal "someEvent", and then you can create an autoconnection to that signal by naming the method "onSomeEvent". That's all.

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

        Hi,

        @nicker-player what exactly are you trying to do ? With which version of Qt ?

        @CassD that's wrong, the onXYZ pattern is used in QML however that's not the case for C++. If you are thinking about the Designer auto connect feature, the pattern is different and it's anyway no recommended to use it.

        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
        2
        • C Offline
          C Offline
          CassD
          wrote on last edited by
          #4

          there's something similar that exists in c++ side that I remember experimenting a bit at my beginning with Qt. Don't remember what exactly but possibly QtWidgets and designer yes. But not recommended indeed.

          1 Reply Last reply
          0
          • nicker playerN Offline
            nicker playerN Offline
            nicker player
            wrote on last edited by
            #5

            I just dont want to input so many codes. i found that if the macro contains the signals key words wouldnt work.so just forget it.

            jsulmJ C 2 Replies Last reply
            0
            • nicker playerN nicker player

              I just dont want to input so many codes. i found that if the macro contains the signals key words wouldnt work.so just forget it.

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

              @nicker-player You can also use "Q_SIGNALS" instead of "signals".
              "it dosent work" - is not a problem description.
              Btw. signals is not a keyword.

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

              nicker playerN 1 Reply Last reply
              0
              • nicker playerN nicker player

                I just dont want to input so many codes. i found that if the macro contains the signals key words wouldnt work.so just forget it.

                C Offline
                C Offline
                CassD
                wrote on last edited by
                #7

                @nicker-player said in how to define a macro function with included the signals key words?:

                I just dont want to input so many codes. i found that if the macro contains the signals key words wouldnt work.so just forget it.

                I don't understand what you want to achieve (and I'm obviously not the only one). Please explain us clearly and correctly what you are trying to do.
                No matter what you are trying to do, the way you are trying to do it is a non-sense.

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  @nicker-player You can also use "Q_SIGNALS" instead of "signals".
                  "it dosent work" - is not a problem description.
                  Btw. signals is not a keyword.

                  nicker playerN Offline
                  nicker playerN Offline
                  nicker player
                  wrote on last edited by
                  #8

                  @jsulm
                  thanks.you just helped me.

                  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