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. Using Q_SIGNAL/Q_SLOT Dsiplays invalid Errors in QTCreator
Forum Updated to NodeBB v4.3 + New Features

Using Q_SIGNAL/Q_SLOT Dsiplays invalid Errors in QTCreator

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 535 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    The Q_SIGNALS and Q_SLOTS are replacements for the
    signals:
    slots:
    in the .h file
    but as far as I know, NOT to be used for the connect.

    for connect, you should rather use the new syntax
    https://wiki.qt.io/New_Signal_Slot_Syntax

    1 Reply Last reply
    2
    • L Offline
      L Offline
      leinad
      wrote on last edited by
      #3

      I'm on 5.15.2 and have been using the old connect syntax with no issues. Why would the new syntax make a difference when I start using the Q_ declaration?

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

        Hi,

        One of the main difference is build time error rather than runtime warning.

        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
        1
        • L leinad

          I'm on 5.15.2 and have been using the old connect syntax with no issues. Why would the new syntax make a difference when I start using the Q_ declaration?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #5

          @leinad

          Hi
          Its really not related as such.
          The Q_SIGNALS is made to make it easier to avoid issues or clashes with other code where the slots: keywords are used for something else.

          The new syntax is compile time checking versus the old macro-based one that will eat almost anything at compile time
          and silently fail at runtime.

          1 Reply Last reply
          1
          • L Offline
            L Offline
            leinad
            wrote on last edited by
            #6

            That's fine but if I'm not concerned about those issues. Is there a way I can use the Q_ declaration with the old syntax. My code works and there are no signal/slot issues so I'm not concerned about the compilation. Unfortunately I'm forced to use the Q_SIGNAL by forces outside my control within my company.

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

              As @mrjj wrote, you just replace the signals and slots words in your header. That's all, nothing to do in your connect statement.

              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
              1
              • L Offline
                L Offline
                leinad
                wrote on last edited by
                #8

                I did that but I still get connect errors inth ecompilation. Here is an example:
                In my headers I define
                Q_SIGNALS:
                bblah ();

                Q_SLOTS:
                bblah_blah();

                sample connect. Same error for all connect statements: (the error is "expected expression" and there is a red line under Q_SIGNAL and Q_SLOT)

                connect(this, Q_SIGNAL(sendDataBaseNameAndTables(QString, QStringList)), displayLatestTimeWorker, Q_SLOT(getDataBaseNameAndTables(QString, QStringList)));

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  leinad
                  wrote on last edited by
                  #9

                  So you are saying, I should have this?
                  connect(this, SIGNAL(sendDataBaseNameAndTables(QString, QStringList)), displayLatestTimeWorker, SLOT(getDataBaseNameAndTables(QString, QStringList)));

                  The way the header defines the signal/shot is how it is interpreted?

                  mrjjM 1 Reply Last reply
                  0
                  • L leinad

                    So you are saying, I should have this?
                    connect(this, SIGNAL(sendDataBaseNameAndTables(QString, QStringList)), displayLatestTimeWorker, SLOT(getDataBaseNameAndTables(QString, QStringList)));

                    The way the header defines the signal/shot is how it is interpreted?

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @leinad

                    Yes. Just use the old syntax if you wish.

                    • The way the header defines the signal/shot is how it is interpreted?
                      Same way as before. Via the MOC tool.
                    1 Reply Last reply
                    1
                    • L Offline
                      L Offline
                      leinad
                      wrote on last edited by
                      #11

                      Great! Thank you.

                      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