Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. How to defined the MACRO CODE for the slots functions?
Forum Updated to NodeBB v4.3 + New Features

How to defined the MACRO CODE for the slots functions?

Scheduled Pinned Locked Moved Unsolved Qt 6
5 Posts 3 Posters 572 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by nicker player
    #1

    I dont want to write so many same codes.
    So i wrote the macro code like this:

    #define DEFINED_SLOT(Func,TYPE) \
        private slots: void slotReady(TYPE value);
    

    When i using these codes ,it seemd dosent work.So how to fix it?
    Or how to wrote for the signal functions by using the macro code?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      This will only work when you use the new signal/slot syntax since moc can't parse this. Also I don't see a big any advantage of your macro.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

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

        I just want to save some time.I dont want to write so many the same codes.
        So anything else to make it possible to solve the problem?

        J.HilkJ Christian EhrlicherC 2 Replies Last reply
        0
        • nicker playerN nicker player

          I just want to save some time.I dont want to write so many the same codes.
          So anything else to make it possible to solve the problem?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @nicker-player use verdigirs

          its the only way to make templated/macroed slots/signals classes/functions


          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.

          1 Reply Last reply
          0
          • nicker playerN nicker player

            I just want to save some time.I dont want to write so many the same codes.
            So anything else to make it possible to solve the problem?

            Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @nicker-player said in How to defined the MACRO CODE for the slots functions?:

            I dont want to write so many the same codes.

            What exactly do you think you're saving here? I would guess the time discussing here is already much more than you're saving.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            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