‘signals’ and 'public slots' does not name a type
-
Hi @lvyonghuan ,
try
Q_SIGNALS
/Q_SIGNAL
andQ_SLOT
/Q_SLOTS
if your IDE/compiler has issues recognizing the keywords. -
@Pl45m4 Thanks, I'll try it.
By the way, I still find it strange that I use QT creator as the IDE. Even if there is a problem with the IDE, the compilation should be normal. But it also reports an error when compiling.
It works. Has the keyword signals been deprecated in the new version?
-
@lvyonghuan said in ‘signals’ and 'public slots' does not name a type:
Has the keyword signals been deprecated in the new version?
Not that I know of... in QtCreator with Qt6.6 that should still work.
The main purpose to use the "other" macros is, when you have multiple thirdparty libraries and they all have their own kinda "signals". So you can clearly differentiate between them and they are not ambiguous anymore.
Is it a compiler error/warning or is just the code model complaining? -
@lvyonghuan
Normally from Qtsignals
is a macro expanding topublic
andslots
is a macro expanding to empty. moc recognizes them to do its work, but the compiler should see the macros. So the compiler at least should not report‘signals’ and 'public slots' does not name a type
. Unless something has#undef
ed them. Which is the only way I can guess you findQ_SIGNALS
etc. are required. So not sure what is going on in your case. -
@JonB said in ‘signals’ and 'public slots' does not name a type:
Unless something has #undefed them
For instance using the
no_keywords
flag :)
This would explain whyQ_SLOTS
works. But I don't know why you would do this directly when starting with Qt -
@lvyonghuan i suspect you have a bad installation of Qt
-
Christian Ehrlicher Lifetime Qt Championreplied to Ronel_qtmaster on last edited by Christian Ehrlicher
@Ronel_qtmaster said in ‘signals’ and 'public slots' does not name a type:
i suspect you have a bad installation of Qt
Why? Just because no_keywords is set as @Pl45m4 pointed out? Don't simply write stuff due to wild unsolicited guesses.
-
@Christian-Ehrlicher Maybe i am wrong but as far as i know signal and slots mechanism is the basis of
event management programming of Qt-based applications.If they're not recognized by the moc what can this means according to you?It is not even normal that a simple qt installation does not recognize it -
@Ronel_qtmaster said in ‘signals’ and 'public slots' does not name a type:
If they're not recognized by the moc what can this means according to you?
If you have compiler errors it is not moc. moc most likely recognizes the keywords just fine. Most likely it is some project setting that turns off the keywords for the compiler. Then it's not your Qt installation that is messed up.
-
@SimonSchroeder OKay thanks.We shall see when he explain more