Using Q_SIGNAL/Q_SLOT Dsiplays invalid Errors in QTCreator
-
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 -
Hi,
One of the main difference is build time error rather than runtime warning.
-
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?
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. -
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.
-
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)));
-
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?
-
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?